diff --git a/dist/handlers/events/messageCreate.js b/dist/handlers/events/messageCreate.js index 22a713339d..9accf436fd 100644 --- a/dist/handlers/events/messageCreate.js +++ b/dist/handlers/events/messageCreate.js @@ -8,23 +8,23 @@ const Interpreter_1 = require("../../core/Interpreter"); const DiscordEventHandler_1 = require("../../structures/extended/DiscordEventHandler"); exports.default = new DiscordEventHandler_1.DiscordEventHandler({ name: "messageCreate", - version: "1.0.1", + version: "1.0.2", description: "This event is fired when someone sends a message", listener: async function (message) { const prefix = await this.getPrefix(message); - const args = message.content - .slice(prefix?.length ?? 0) - .trim() - .split(/ +/g); - const name = prefix ? args.shift()?.toLowerCase() : args[0]; - const commands = this.commands.get("messageCreate").filter( + const content = message.content.trim(); + const hasPrefix = prefix !== null; + const rawArgs = (hasPrefix ? content.slice(prefix.length) : content).trim().split(/ +/g); + const name = rawArgs[0]?.toLowerCase(); + const commands = this.commands.get("messageCreate").filter((cmd) => // Allow always execute commands - (cmd) => !cmd.name || - ( // Check if it matches the command name or one of aliases - (cmd.name === name || !!cmd.data.aliases?.includes(name)) && + !cmd.name || + // Check if it matches the command name or one of aliases + ((cmd.name === name || !!cmd.data.aliases?.includes(name)) && // If unprefixed there can be no prefix - (cmd.data.unprefixed ? true : !!prefix))); + (cmd.data.unprefixed ? true : hasPrefix))); for (const command of commands) { + const args = command.name ? rawArgs.slice(1) : rawArgs; Interpreter_1.Interpreter.run({ obj: message, command, @@ -39,6 +39,6 @@ exports.default = new DiscordEventHandler_1.DiscordEventHandler({ }); } }, - intents: ["GuildMessages", "DirectMessages"], + intents: ["GuildMessages", "DirectMessages", "MessageContent"], }); //# sourceMappingURL=messageCreate.js.map \ No newline at end of file diff --git a/dist/handlers/events/messageCreate.js.map b/dist/handlers/events/messageCreate.js.map index da60278b3c..27d141508a 100644 --- a/dist/handlers/events/messageCreate.js.map +++ b/dist/handlers/events/messageCreate.js.map @@ -1 +1 @@ -{"version":3,"file":"messageCreate.js","sourceRoot":"","sources":["../../../src/handlers/events/messageCreate.ts"],"names":[],"mappings":";AAAA;;;EAGE;;AAEF,wDAAoD;AACpD,uFAAmF;AAEnF,kBAAe,IAAI,yCAAmB,CAAC;IACnC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,kDAAkD;IAC/D,QAAQ,EAAE,KAAK,WAAW,OAAO;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAE5C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO;aACvB,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;aAC1B,IAAI,EAAE;aACN,KAAK,CAAC,KAAK,CAAC,CAAA;QACjB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAE3D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,MAAM;QACtD,gCAAgC;QAChC,CAAC,GAAG,EAAE,EAAE,CACJ,CAAC,GAAG,CAAC,IAAI;YACT,EAAC,yDAAyD;YACtD,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAK,CAAC,CAAC;gBAC1D,uCAAuC;gBACvC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CACnD,CAAA;QAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,yBAAW,CAAC,GAAG,CAAC;gBACZ,GAAG,EAAE,OAAO;gBACZ,OAAO;gBACP,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE;oBACJ,OAAO,EAAE;wBACL,GAAG,EAAE,OAAO;qBACf;iBACJ;gBACD,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAC3B,IAAI;aACP,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IACD,OAAO,EAAE,CAAC,eAAe,EAAE,gBAAgB,CAAC;CAC/C,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"messageCreate.js","sourceRoot":"","sources":["../../../src/handlers/events/messageCreate.ts"],"names":[],"mappings":";AAAA;;;EAGE;;AAEF,wDAAoD;AACpD,uFAAmF;AAEnF,kBAAe,IAAI,yCAAmB,CAAC;IACnC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,kDAAkD;IAC/D,QAAQ,EAAE,KAAK,WAAW,OAAO;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;QACtC,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,CAAA;QACjC,MAAM,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,MAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACzF,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAA;QAEtC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,MAAM,CACtD,CAAC,GAAG,EAAE,EAAE;QACJ,gCAAgC;QAChC,CAAC,GAAG,CAAC,IAAI;YACT,yDAAyD;YACzD,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAK,CAAC,CAAC;gBACvD,uCAAuC;gBACvC,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CACpD,CAAA;QAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;YAEtD,yBAAW,CAAC,GAAG,CAAC;gBACZ,GAAG,EAAE,OAAO;gBACZ,OAAO;gBACP,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE;oBACJ,OAAO,EAAE;wBACL,GAAG,EAAE,OAAO;qBACf;iBACJ;gBACD,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAC3B,IAAI;aACP,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IACD,OAAO,EAAE,CAAC,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,CAAC;CACjE,CAAC,CAAA"} \ No newline at end of file diff --git a/metadata/events.json b/metadata/events.json index 75171947aa..c3edb72349 100644 --- a/metadata/events.json +++ b/metadata/events.json @@ -1 +1 @@ -[{"name":"autoModerationActionExecution","version":"1.2.0","description":"This event is fired when an automod is fired under a message","intents":["Guilds","AutoModerationExecution"]},{"name":"autoModerationRuleCreate","version":"1.5.0","description":"This event is fired when an automod rule is created","intents":["Guilds","AutoModerationConfiguration"]},{"name":"autoModerationRuleDelete","version":"1.5.0","description":"This event is fired when an automod rule is deleted","intents":["Guilds","AutoModerationConfiguration"]},{"name":"autoModerationRuleUpdate","version":"1.5.0","description":"This event is fired when an automod rule is updated","intents":["Guilds","AutoModerationConfiguration"]},{"name":"channelCreate","version":"1.0.1","description":"This event is fired when a channel is created","intents":["Guilds"]},{"name":"channelDelete","version":"1.0.1","description":"This event is fired when a channel is deleted","intents":["Guilds"]},{"name":"channelPinsUpdate","version":"1.4.0","description":"This event is fired when a channel's pins are updated","intents":["Guilds","DirectMessages"]},{"name":"channelUpdate","version":"1.0.1","intents":["Guilds"],"description":"This event is fired when a channel is updated"},{"name":"clientReady","version":"1.0.1","description":"This event is fired when the bot becomes ready"},{"name":"debug","version":"1.0.1","description":"This event is fired when discord.js sends out debug info"},{"name":"emojiCreate","version":"1.0.1","description":"This event is fired when an emoji is created","intents":["GuildExpressions"]},{"name":"emojiDelete","version":"1.0.1","description":"This event is fired when an emoji is deleted","intents":["GuildExpressions"]},{"name":"emojiUpdate","version":"1.0.1","intents":["GuildExpressions"],"description":"This event is fired when an emoji is updated"},{"name":"entitlementCreate","version":"1.5.0","description":"This event is fired when an entitlement is created"},{"name":"entitlementDelete","version":"1.5.0","description":"This event is fired when an entitlement is deleted"},{"name":"entitlementUpdate","version":"1.5.0","description":"This event is fired when an entitlement is updated"},{"name":"error","version":"1.0.1","description":"This event is fired when an error happens on the client"},{"name":"guildAuditLogEntryCreate","version":"1.0.3","description":"This event is fired when a guild audit log entry is created","intents":["Guilds","GuildModeration"]},{"name":"guildAvailable","version":"1.4.0","description":"This event is fired when a guild becomes available","intents":["Guilds"]},{"name":"guildBanAdd","version":"1.4.0","description":"This event is fired when a member is banned from the guild","intents":["GuildMembers","GuildModeration"]},{"name":"guildBanRemove","version":"1.4.0","description":"This event is fired when a member is unbanned from a guild","intents":["GuildMembers","GuildModeration"]},{"name":"guildCreate","version":"1.0.1","description":"This event is fired when the bot is added to a guild","intents":["Guilds"]},{"name":"guildDelete","version":"1.0.1","description":"This event is fired when a guild is deleted","intents":["Guilds"]},{"name":"guildIntegrationsUpdate","version":"2.5.0","description":"This event is fired when an integration is updated on a guild","intents":["GuildIntegrations"]},{"name":"guildMemberAdd","version":"1.0.1","description":"This event is fired when a member joins the guild","intents":["GuildMembers"]},{"name":"guildMemberAvailable","version":"1.4.0","description":"This event is fired when a member of a guild becomes available","intents":["GuildMembers"]},{"name":"guildMemberRemove","version":"1.0.1","description":"This event is fired when a member leaves, is kicked or banned from a guild","intents":["GuildMembers"]},{"name":"guildMemberUpdate","version":"1.0.1","description":"This event is fired when a member is updated in a guild","intents":["GuildMembers"]},{"name":"guildScheduledEventCreate","version":"1.4.0","description":"This event is called when a scheduled event is created","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventDelete","version":"1.4.0","description":"This event is called when a scheduled event is deleted","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventUpdate","version":"1.4.0","description":"This event is called when a scheduled event is updated","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventUserAdd","version":"1.4.0","description":"This event is called when a user is added to a scheduled event","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventUserRemove","version":"1.4.0","description":"This event is called when a user is removed from a scheduled event","intents":["GuildScheduledEvents"]},{"name":"guildSoundboardSoundCreate","version":"2.4.0","description":"This event is fired when a soundboard sound is created","intents":["GuildExpressions"]},{"name":"guildSoundboardSoundDelete","version":"2.4.0","description":"This event is fired when a soundboard sound is deleted","intents":["GuildExpressions"]},{"name":"guildSoundboardSoundUpdate","version":"2.4.0","description":"This event is fired when a soundboard sound is updated","intents":["GuildExpressions"]},{"name":"guildUnavailable","version":"1.4.0","description":"This event is fired when a guild becomes unavailable","intents":["Guilds"]},{"name":"guildUpdate","version":"1.0.1","description":"This event is fired when a guild updates their settings","intents":["Guilds"]},{"name":"interactionCreate","version":"1.0.1","description":"This event is fired every time a user uses a slash command, context menu, button, etc"},{"name":"inviteCreate","version":"1.0.3","description":"This event is fired when an invite is created","intents":["Guilds","GuildInvites"]},{"name":"inviteDelete","version":"1.0.3","description":"This event is fired when an invite is deleted","intents":["Guilds","GuildInvites"]},{"name":"messageCreate","version":"1.0.1","description":"This event is fired when someone sends a message","intents":["GuildMessages","DirectMessages"]},{"name":"messageDelete","version":"1.0.1","description":"This event is fired when a message is deleted","intents":["GuildMessages","DirectMessages"]},{"name":"messageDeleteBulk","version":"1.4.0","description":"This event is fired when a row of messages is deleted","intents":["GuildMessages"]},{"name":"messagePollVoteAdd","version":"1.5.0","description":"This event is fired when a poll vote is added","intents":["GuildMessagePolls","DirectMessagePolls"]},{"name":"messagePollVoteRemove","version":"1.5.0","description":"This event is fired when a poll vote is removed","intents":["GuildMessagePolls","DirectMessagePolls"]},{"name":"messageReactionAdd","version":"1.0.1","description":"This event is fired when a reaction is added","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageReactionRemove","version":"1.0.1","description":"This event is fired when a user stops reacting","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageReactionRemoveAll","version":"1.4.0","description":"This event is fired when all emojis are removed from a message's reactions","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageReactionRemoveEmoji","version":"1.4.0","description":"This event is fired when an emoji is removed from a message's reactions","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageUpdate","version":"1.0.1","description":"This event is fired when a message is updated","intents":["GuildMessages","DirectMessages"]},{"name":"presenceUpdate","version":"1.1.0","description":"This event is fired when a presence is updated","intents":["Guilds","GuildPresences"]},{"name":"roleCreate","version":"1.0.1","description":"This event is fired when a role is created","intents":["Guilds"]},{"name":"roleDelete","version":"1.0.1","description":"This event is fired when a role is deleted","intents":["Guilds"]},{"name":"roleUpdate","version":"1.0.1","description":"This event is fired when a role is updated","intents":["Guilds"]},{"name":"shardDisconnect","version":"1.0.1","description":"This event is fired when a shard is disconnected"},{"name":"shardError","version":"1.0.1","description":"This event is fired when a shard throws an error"},{"name":"shardReady","version":"1.0.1","description":"Event is executed when a shard of this bot becomes ready"},{"name":"shardReconnecting","version":"1.0.1","description":"This event is fired when a shard starts reconnecting"},{"name":"shardResume","version":"1.0.1","description":"This event is fired when a shard starts resuming"},{"name":"stageInstanceCreate","version":"1.4.0","description":"This event is fired when a stage is created","intents":["Guilds"]},{"name":"stageInstanceDelete","version":"1.4.0","description":"This event is fired when a stage is deleted","intents":["Guilds"]},{"name":"stageInstanceUpdate","version":"1.4.0","description":"This event is fired when a stage is updated","intents":["Guilds"]},{"name":"stickerCreate","version":"1.4.0","description":"This event is fired when an sticker is created","intents":["GuildExpressions"]},{"name":"stickerDelete","version":"1.4.0","description":"This event is fired when an sticker is deleted","intents":["GuildExpressions"]},{"name":"stickerUpdate","version":"1.4.0","description":"This event is fired when an sticker is updated","intents":["GuildExpressions"]},{"name":"subscriptionCreate","version":"2.5.0","description":"This event is fired when a subscription is created"},{"name":"subscriptionDelete","version":"2.5.0","description":"This event is fired when a subscription is deleted"},{"name":"subscriptionUpdate","version":"2.5.0","description":"This event is fired when a subscription is updated"},{"name":"threadCreate","version":"1.4.0","description":"This event is fired when a thread is created","intents":["Guilds"]},{"name":"threadDelete","version":"1.4.0","description":"This event is fired when a thread is deleted","intents":["Guilds"]},{"name":"threadMemberUpdate","version":"1.0.1","description":"This event is fired when a thread member is updated in a guild","intents":["Guilds","GuildMembers"]},{"name":"threadUpdate","version":"1.4.0","intents":["Guilds"],"description":"This event is fired when a thread is updated"},{"name":"typingStart","version":"1.4.0","description":"This event is fired when a user starts typing","intents":["GuildMessageTyping","DirectMessageTyping"]},{"name":"userUpdate","version":"1.0.1","description":"This event is fired when a user updates their profile","intents":["GuildMembers"]},{"name":"voiceChannelEffectSend","version":"2.3.0","description":"This event is fired when a user sends an effect in a voice channel","intents":["GuildVoiceStates"]},{"name":"voiceServerUpdate","version":"2.7.0","description":"This event is fired when a voice server is updated","intents":["GuildVoiceStates"]},{"name":"voiceStateUpdate","version":"1.0.1","description":"This event is fired when a user joins/leaves a voice channel","intents":["GuildVoiceStates"]},{"name":"webhooksUpdate","version":"2.5.0","description":"This event is fired when a webhook is updated","intents":["GuildWebhooks"]}] \ No newline at end of file +[{"name":"autoModerationActionExecution","version":"1.2.0","description":"This event is fired when an automod is fired under a message","intents":["Guilds","AutoModerationExecution"]},{"name":"autoModerationRuleCreate","version":"1.5.0","description":"This event is fired when an automod rule is created","intents":["Guilds","AutoModerationConfiguration"]},{"name":"autoModerationRuleDelete","version":"1.5.0","description":"This event is fired when an automod rule is deleted","intents":["Guilds","AutoModerationConfiguration"]},{"name":"autoModerationRuleUpdate","version":"1.5.0","description":"This event is fired when an automod rule is updated","intents":["Guilds","AutoModerationConfiguration"]},{"name":"channelCreate","version":"1.0.1","description":"This event is fired when a channel is created","intents":["Guilds"]},{"name":"channelDelete","version":"1.0.1","description":"This event is fired when a channel is deleted","intents":["Guilds"]},{"name":"channelPinsUpdate","version":"1.4.0","description":"This event is fired when a channel's pins are updated","intents":["Guilds","DirectMessages"]},{"name":"channelUpdate","version":"1.0.1","intents":["Guilds"],"description":"This event is fired when a channel is updated"},{"name":"clientReady","version":"1.0.1","description":"This event is fired when the bot becomes ready"},{"name":"debug","version":"1.0.1","description":"This event is fired when discord.js sends out debug info"},{"name":"emojiCreate","version":"1.0.1","description":"This event is fired when an emoji is created","intents":["GuildExpressions"]},{"name":"emojiDelete","version":"1.0.1","description":"This event is fired when an emoji is deleted","intents":["GuildExpressions"]},{"name":"emojiUpdate","version":"1.0.1","intents":["GuildExpressions"],"description":"This event is fired when an emoji is updated"},{"name":"entitlementCreate","version":"1.5.0","description":"This event is fired when an entitlement is created"},{"name":"entitlementDelete","version":"1.5.0","description":"This event is fired when an entitlement is deleted"},{"name":"entitlementUpdate","version":"1.5.0","description":"This event is fired when an entitlement is updated"},{"name":"error","version":"1.0.1","description":"This event is fired when an error happens on the client"},{"name":"guildAuditLogEntryCreate","version":"1.0.3","description":"This event is fired when a guild audit log entry is created","intents":["Guilds","GuildModeration"]},{"name":"guildAvailable","version":"1.4.0","description":"This event is fired when a guild becomes available","intents":["Guilds"]},{"name":"guildBanAdd","version":"1.4.0","description":"This event is fired when a member is banned from the guild","intents":["GuildMembers","GuildModeration"]},{"name":"guildBanRemove","version":"1.4.0","description":"This event is fired when a member is unbanned from a guild","intents":["GuildMembers","GuildModeration"]},{"name":"guildCreate","version":"1.0.1","description":"This event is fired when the bot is added to a guild","intents":["Guilds"]},{"name":"guildDelete","version":"1.0.1","description":"This event is fired when a guild is deleted","intents":["Guilds"]},{"name":"guildIntegrationsUpdate","version":"2.5.0","description":"This event is fired when an integration is updated on a guild","intents":["GuildIntegrations"]},{"name":"guildMemberAdd","version":"1.0.1","description":"This event is fired when a member joins the guild","intents":["GuildMembers"]},{"name":"guildMemberAvailable","version":"1.4.0","description":"This event is fired when a member of a guild becomes available","intents":["GuildMembers"]},{"name":"guildMemberRemove","version":"1.0.1","description":"This event is fired when a member leaves, is kicked or banned from a guild","intents":["GuildMembers"]},{"name":"guildMemberUpdate","version":"1.0.1","description":"This event is fired when a member is updated in a guild","intents":["GuildMembers"]},{"name":"guildScheduledEventCreate","version":"1.4.0","description":"This event is called when a scheduled event is created","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventDelete","version":"1.4.0","description":"This event is called when a scheduled event is deleted","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventUpdate","version":"1.4.0","description":"This event is called when a scheduled event is updated","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventUserAdd","version":"1.4.0","description":"This event is called when a user is added to a scheduled event","intents":["GuildScheduledEvents"]},{"name":"guildScheduledEventUserRemove","version":"1.4.0","description":"This event is called when a user is removed from a scheduled event","intents":["GuildScheduledEvents"]},{"name":"guildSoundboardSoundCreate","version":"2.4.0","description":"This event is fired when a soundboard sound is created","intents":["GuildExpressions"]},{"name":"guildSoundboardSoundDelete","version":"2.4.0","description":"This event is fired when a soundboard sound is deleted","intents":["GuildExpressions"]},{"name":"guildSoundboardSoundUpdate","version":"2.4.0","description":"This event is fired when a soundboard sound is updated","intents":["GuildExpressions"]},{"name":"guildUnavailable","version":"1.4.0","description":"This event is fired when a guild becomes unavailable","intents":["Guilds"]},{"name":"guildUpdate","version":"1.0.1","description":"This event is fired when a guild updates their settings","intents":["Guilds"]},{"name":"interactionCreate","version":"1.0.1","description":"This event is fired every time a user uses a slash command, context menu, button, etc"},{"name":"inviteCreate","version":"1.0.3","description":"This event is fired when an invite is created","intents":["Guilds","GuildInvites"]},{"name":"inviteDelete","version":"1.0.3","description":"This event is fired when an invite is deleted","intents":["Guilds","GuildInvites"]},{"name":"messageCreate","version":"1.0.2","description":"This event is fired when someone sends a message","intents":["GuildMessages","DirectMessages","MessageContent"]},{"name":"messageDelete","version":"1.0.1","description":"This event is fired when a message is deleted","intents":["GuildMessages","DirectMessages"]},{"name":"messageDeleteBulk","version":"1.4.0","description":"This event is fired when a row of messages is deleted","intents":["GuildMessages"]},{"name":"messagePollVoteAdd","version":"1.5.0","description":"This event is fired when a poll vote is added","intents":["GuildMessagePolls","DirectMessagePolls"]},{"name":"messagePollVoteRemove","version":"1.5.0","description":"This event is fired when a poll vote is removed","intents":["GuildMessagePolls","DirectMessagePolls"]},{"name":"messageReactionAdd","version":"1.0.1","description":"This event is fired when a reaction is added","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageReactionRemove","version":"1.0.1","description":"This event is fired when a user stops reacting","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageReactionRemoveAll","version":"1.4.0","description":"This event is fired when all emojis are removed from a message's reactions","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageReactionRemoveEmoji","version":"1.4.0","description":"This event is fired when an emoji is removed from a message's reactions","intents":["GuildMessageReactions","DirectMessageReactions"]},{"name":"messageUpdate","version":"1.0.1","description":"This event is fired when a message is updated","intents":["GuildMessages","DirectMessages"]},{"name":"presenceUpdate","version":"1.1.0","description":"This event is fired when a presence is updated","intents":["Guilds","GuildPresences"]},{"name":"roleCreate","version":"1.0.1","description":"This event is fired when a role is created","intents":["Guilds"]},{"name":"roleDelete","version":"1.0.1","description":"This event is fired when a role is deleted","intents":["Guilds"]},{"name":"roleUpdate","version":"1.0.1","description":"This event is fired when a role is updated","intents":["Guilds"]},{"name":"shardDisconnect","version":"1.0.1","description":"This event is fired when a shard is disconnected"},{"name":"shardError","version":"1.0.1","description":"This event is fired when a shard throws an error"},{"name":"shardReady","version":"1.0.1","description":"Event is executed when a shard of this bot becomes ready"},{"name":"shardReconnecting","version":"1.0.1","description":"This event is fired when a shard starts reconnecting"},{"name":"shardResume","version":"1.0.1","description":"This event is fired when a shard starts resuming"},{"name":"stageInstanceCreate","version":"1.4.0","description":"This event is fired when a stage is created","intents":["Guilds"]},{"name":"stageInstanceDelete","version":"1.4.0","description":"This event is fired when a stage is deleted","intents":["Guilds"]},{"name":"stageInstanceUpdate","version":"1.4.0","description":"This event is fired when a stage is updated","intents":["Guilds"]},{"name":"stickerCreate","version":"1.4.0","description":"This event is fired when an sticker is created","intents":["GuildExpressions"]},{"name":"stickerDelete","version":"1.4.0","description":"This event is fired when an sticker is deleted","intents":["GuildExpressions"]},{"name":"stickerUpdate","version":"1.4.0","description":"This event is fired when an sticker is updated","intents":["GuildExpressions"]},{"name":"subscriptionCreate","version":"2.5.0","description":"This event is fired when a subscription is created"},{"name":"subscriptionDelete","version":"2.5.0","description":"This event is fired when a subscription is deleted"},{"name":"subscriptionUpdate","version":"2.5.0","description":"This event is fired when a subscription is updated"},{"name":"threadCreate","version":"1.4.0","description":"This event is fired when a thread is created","intents":["Guilds"]},{"name":"threadDelete","version":"1.4.0","description":"This event is fired when a thread is deleted","intents":["Guilds"]},{"name":"threadMemberUpdate","version":"1.0.1","description":"This event is fired when a thread member is updated in a guild","intents":["Guilds","GuildMembers"]},{"name":"threadUpdate","version":"1.4.0","intents":["Guilds"],"description":"This event is fired when a thread is updated"},{"name":"typingStart","version":"1.4.0","description":"This event is fired when a user starts typing","intents":["GuildMessageTyping","DirectMessageTyping"]},{"name":"userUpdate","version":"1.0.1","description":"This event is fired when a user updates their profile","intents":["GuildMembers"]},{"name":"voiceChannelEffectSend","version":"2.3.0","description":"This event is fired when a user sends an effect in a voice channel","intents":["GuildVoiceStates"]},{"name":"voiceServerUpdate","version":"2.7.0","description":"This event is fired when a voice server is updated","intents":["GuildVoiceStates"]},{"name":"voiceStateUpdate","version":"1.0.1","description":"This event is fired when a user joins/leaves a voice channel","intents":["GuildVoiceStates"]},{"name":"webhooksUpdate","version":"2.5.0","description":"This event is fired when a webhook is updated","intents":["GuildWebhooks"]}] \ No newline at end of file diff --git a/src/handlers/events/messageCreate.ts b/src/handlers/events/messageCreate.ts index 8ae868fb44..59a198301d 100644 --- a/src/handlers/events/messageCreate.ts +++ b/src/handlers/events/messageCreate.ts @@ -8,28 +8,28 @@ import { DiscordEventHandler } from "../../structures/extended/DiscordEventHandl export default new DiscordEventHandler({ name: "messageCreate", - version: "1.0.1", + version: "1.0.2", description: "This event is fired when someone sends a message", listener: async function (message) { const prefix = await this.getPrefix(message) - - const args = message.content - .slice(prefix?.length ?? 0) - .trim() - .split(/ +/g) - const name = prefix ? args.shift()?.toLowerCase() : args[0] + const content = message.content.trim() + const hasPrefix = prefix !== null + const rawArgs = (hasPrefix ? content.slice(prefix!.length) : content).trim().split(/ +/g) + const name = rawArgs[0]?.toLowerCase() const commands = this.commands.get("messageCreate").filter( - // Allow always execute commands (cmd) => + // Allow always execute commands !cmd.name || - (// Check if it matches the command name or one of aliases - (cmd.name === name || !!cmd.data.aliases?.includes(name!)) && + // Check if it matches the command name or one of aliases + ((cmd.name === name || !!cmd.data.aliases?.includes(name!)) && // If unprefixed there can be no prefix - (cmd.data.unprefixed ? true : !!prefix)) + (cmd.data.unprefixed ? true : hasPrefix)) ) for (const command of commands) { + const args = command.name ? rawArgs.slice(1) : rawArgs + Interpreter.run({ obj: message, command, @@ -44,5 +44,5 @@ export default new DiscordEventHandler({ }) } }, - intents: ["GuildMessages", "DirectMessages"], -}) + intents: ["GuildMessages", "DirectMessages", "MessageContent"], +}) \ No newline at end of file