Skip to content

Commit

Permalink
Make ignoring bots toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
some-boi committed Jul 30, 2022
1 parent 351b87a commit 42df056
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export function enableAmethystPlugin<
},
],
]);
bot.ignoreBots = options?.ignoreBots ?? true;
bot.messageQuotedArguments = options?.messageQuotedArguments ?? false;
bot.messageCollectors = new AmethystCollection();
bot.componentCollectors = new AmethystCollection();
Expand Down
5 changes: 5 additions & 0 deletions src/handlers/messageCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export async function handleMessageCommands(
(cmd as Command<"message">).aliases?.includes(commandName!)
)
) as Command<"message">;
if (
bot.users.get(message.authorId)?.toggles.bot &&
(command.ignoreBots ?? bot.ignoreBots)
)
return;
if (!command) return bot.events.commandNotFound?.(bot, message, commandName);
args =
command.quotedArguments === true ||
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/AmethystBotOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export type AmethystBotOptions = {
| string[]
| ((bot: AmethystBot, message: Message) => Async<string | string[]>);
botMentionAsPrefix?: boolean;
/**ignore bots when they try to use message commands, default to `true`*/
ignoreBots?: boolean;
messageQuotedArguments?: boolean;
defaultCooldown?: CommandCooldown;
ignoreCooldown?: (string | bigint)[];
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ interface AmethystProps extends Omit<BotWithCache, "events"> {
ignoreCooldown?: bigint[];
guildOnly?: boolean;
messageQuotedArguments?: boolean;
ignoreBots?: boolean;
dmOnly?: boolean;
prefix?:
| string
Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type Command<T extends "application" | "message" = never> = {
/**The guild permissions needed by the bot to execute the command*/
botGuildPermissions?: PermissionStrings[];
}
| {
| {
/**If the command can only be used in dms*/
dmOnly?: true;
/**If the command can only be used in guilds*/
Expand Down Expand Up @@ -96,6 +96,8 @@ export type Command<T extends "application" | "message" = never> = {
? {
aliases?: string[];
quotedArguments?: boolean;
/**Ignore bots when they try to use the command*/
ignoreBots?: boolean;
}
: Record<never, never>);

Expand Down

0 comments on commit 42df056

Please sign in to comment.