mirror of
https://github.com/xHyroM/roles-bot.git
synced 2024-11-24 09:11:05 +01:00
Merge branch 'rewrite' of https://github.com/xHyroM/roles-bot into rewrite
This commit is contained in:
commit
f25e3fdcd4
3 changed files with 16 additions and 9 deletions
|
@ -88,14 +88,18 @@ export default {
|
||||||
return new Response("Unknown component", { status: 404 });
|
return new Response("Unknown component", { status: 404 });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return respond({
|
if (component.acknowledge)
|
||||||
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
return respond({
|
||||||
data: {
|
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
||||||
flags: component.flags,
|
data: {
|
||||||
},
|
flags: component.flags,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
component.run(new ComponentContext(interaction, env));
|
if (component.acknowledge)
|
||||||
|
component.run(new ComponentContext(interaction, env));
|
||||||
|
// rome-ignore lint/correctness/noUnsafeFinally: it works, must do better typings etc...
|
||||||
|
else return component.run(new ComponentContext(interaction, env));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ interface CommandOptions {
|
||||||
run: (interaction: CommandContext) => void;
|
run: (interaction: CommandContext) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Command<A> {
|
export class Command {
|
||||||
public name: string;
|
public name: string;
|
||||||
public acknowledge: boolean;
|
public acknowledge: boolean;
|
||||||
public flags: MessageFlags | undefined;
|
public flags: MessageFlags | undefined;
|
||||||
|
|
|
@ -4,17 +4,20 @@ import { ComponentContext } from "./contexts/ComponentContext";
|
||||||
|
|
||||||
interface ComponentOptions {
|
interface ComponentOptions {
|
||||||
id: string;
|
id: string;
|
||||||
|
acknowledge?: boolean;
|
||||||
flags?: MessageFlags;
|
flags?: MessageFlags;
|
||||||
run: (interaction: ComponentContext) => void;
|
run: (interaction: ComponentContext) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Component {
|
export class Component {
|
||||||
public id: string;
|
public id: string;
|
||||||
|
public acknowledge: boolean;
|
||||||
public flags: MessageFlags | undefined;
|
public flags: MessageFlags | undefined;
|
||||||
public run: (interaction: ComponentContext) => void;
|
public run: (interaction: ComponentContext) => void | Response;
|
||||||
|
|
||||||
constructor(options: ComponentOptions) {
|
constructor(options: ComponentOptions) {
|
||||||
this.id = options.id;
|
this.id = options.id;
|
||||||
|
this.acknowledge = options.acknowledge ?? true;
|
||||||
this.flags = options.flags;
|
this.flags = options.flags;
|
||||||
this.run = options.run;
|
this.run = options.run;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue