forked from Galactic/galactic-bot
Bugfix to lockdown replying multiple times without edit
This commit is contained in:
parent
c875ac2e2f
commit
720738d7ab
@ -1,2 +0,0 @@
|
||||
[*]
|
||||
end_of_line = lf
|
@ -248,7 +248,6 @@
|
||||
"warn",
|
||||
"before"
|
||||
],
|
||||
"padding-line-between-statements": "warn",
|
||||
"padded-blocks": [
|
||||
"warn",
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "yarn build && node --enable-source-maps build/index.js",
|
||||
"dev": "nodemon --signal SIGINT --delay 5 -e js --trace-warnings --unhandled-rejections=strict build/index.js",
|
||||
"dev": "nodemon --delay 5 -e js --trace-warnings --unhandled-rejections=strict build/index.js",
|
||||
"debug": "node --trace-warnings --inspect index.js",
|
||||
"update": "git pull && cd api && yarn update",
|
||||
"test": "jest --detectOpenHandles",
|
||||
@ -18,7 +18,7 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Navy-gif/New-GBot.git"
|
||||
},
|
||||
"author": "Navy.gif & Nolan",
|
||||
"author": "Navy.gif",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Navy-gif/New-GBot/issues"
|
||||
|
@ -7,7 +7,6 @@ import InvokerWrapper from '../../wrappers/InvokerWrapper.js';
|
||||
|
||||
class LockdownCommand extends ModerationCommand
|
||||
{
|
||||
|
||||
constructor (client: DiscordClient)
|
||||
{
|
||||
super(client, {
|
||||
@ -30,23 +29,21 @@ class LockdownCommand extends ModerationCommand
|
||||
clientPermissions: [ 'ManageChannels', 'ManageRoles' ],
|
||||
skipOptions: [ 'users', 'points', 'expiration', 'force', 'silent' ]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async execute (invoker: InvokerWrapper, { channels, ...args }: CommandParams)
|
||||
{
|
||||
|
||||
if (!channels)
|
||||
throw new CommandError(invoker, { index: 'MODERATION_MISSING_CHANNELS' });
|
||||
|
||||
await invoker.reply({ content: 'Working...', emoji: 'loading' });
|
||||
return this.client.moderation.handleInfraction(Lockdown, invoker, {
|
||||
const content = await this.client.moderation.handleInfraction(Lockdown, invoker, {
|
||||
targets: channels?.asChannels as TextChannel[],
|
||||
args
|
||||
});
|
||||
|
||||
if (typeof content === 'string')
|
||||
await invoker.reply({ content, edit: true });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LockdownCommand;
|
@ -31,16 +31,16 @@ class UnlockdownCommand extends ModerationCommand
|
||||
|
||||
async execute (invoker: InvokerWrapper, { channels, ...args }: CommandParams)
|
||||
{
|
||||
|
||||
if (!channels)
|
||||
throw new CommandError(invoker, { index: 'MODERATION_MISSING_CHANNELS' });
|
||||
|
||||
await invoker.reply({ content: 'Working...', emoji: 'loading' });
|
||||
return this.client.moderation.handleInfraction(Unlockdown, invoker, {
|
||||
const content = await this.client.moderation.handleInfraction(Unlockdown, invoker, {
|
||||
targets: channels?.asChannels as TextChannel[],
|
||||
args
|
||||
});
|
||||
|
||||
if (typeof content === 'string')
|
||||
await invoker.reply({ content, edit: true });
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class CommandHandler extends Observer
|
||||
}
|
||||
|
||||
//
|
||||
async messageCreate (message: ExtendedMessage)
|
||||
private async messageCreate (message: ExtendedMessage)
|
||||
{
|
||||
if (!this.client.ready
|
||||
|| message.webhookId
|
||||
@ -103,7 +103,7 @@ class CommandHandler extends Observer
|
||||
await this._executeCommand(invoker, result.options ?? {});
|
||||
}
|
||||
|
||||
async interactionCreate (interaction: InteractionWrapper)
|
||||
private async interactionCreate (interaction: InteractionWrapper)
|
||||
{
|
||||
if (!interaction.isCommand()
|
||||
&& !interaction.isContextMenu())
|
||||
@ -144,7 +144,7 @@ class CommandHandler extends Observer
|
||||
}
|
||||
}
|
||||
|
||||
async _parseResult (invoker: InvokerWrapper<true, true>, response: ParseResult)
|
||||
private async _parseResult (invoker: InvokerWrapper<true, true>, response: ParseResult)
|
||||
{
|
||||
// Ensure option dependencies
|
||||
outer:
|
||||
@ -215,7 +215,7 @@ class CommandHandler extends Observer
|
||||
}
|
||||
}
|
||||
|
||||
async _handleInhibitors (invoker: InvokerWrapper<true, true>)
|
||||
private async _handleInhibitors (invoker: InvokerWrapper<true, true>)
|
||||
{
|
||||
const inhibitors = this.client.registry.components.filter<Inhibitor>((comp): comp is Inhibitor => comp.type === 'inhibitor' && !comp.disabled);
|
||||
if (!inhibitors.size)
|
||||
@ -236,7 +236,7 @@ class CommandHandler extends Observer
|
||||
return errors.sort((a, b) => b.inhibitor.priority - a.inhibitor.priority);
|
||||
}
|
||||
|
||||
async _executeCommand (invoker: InvokerWrapper<true, true>, options: { [key: string]: CommandOption })
|
||||
private async _executeCommand (invoker: InvokerWrapper<true, true>, options: { [key: string]: CommandOption })
|
||||
{
|
||||
let response = null;
|
||||
if (this.client.developmentMode && !this.client.developers.includes(invoker.user.id))
|
||||
@ -295,7 +295,7 @@ class CommandHandler extends Observer
|
||||
return invoker.reply({ index: 'O_COMMANDHANDLER_COMMAND_NORESPONSE', ephemeral: !invoker.replied });
|
||||
}
|
||||
|
||||
async _parseInteraction (invoker: InvokerWrapper<true, true>, command: Command): Promise<ParseResult>
|
||||
private async _parseInteraction (invoker: InvokerWrapper<true, true>, command: Command): Promise<ParseResult>
|
||||
{
|
||||
const { subcommand, guild } = invoker;
|
||||
const interaction = invoker.target as InteractionWrapper;
|
||||
@ -354,7 +354,7 @@ class CommandHandler extends Observer
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-lines-per-function
|
||||
async _parseMessage (invoker: InvokerWrapper<true, true>, params: (string | null)[]): Promise<ParseResult>
|
||||
private async _parseMessage (invoker: InvokerWrapper<true, true>, params: (string | null)[]): Promise<ParseResult>
|
||||
{
|
||||
const { command, guild } = invoker;
|
||||
const message = invoker.target as MessageWrapper;
|
||||
@ -599,7 +599,7 @@ class CommandHandler extends Observer
|
||||
return { options: args, verbose: true };
|
||||
}
|
||||
|
||||
async _getCommand (message: MessageWrapper)
|
||||
private async _getCommand (message: MessageWrapper)
|
||||
{
|
||||
if (!this.#mentionPattern)
|
||||
this.#mentionPattern = new RegExp(`^(<@!?${this.client.user!.id}>)`, 'iu');
|
||||
@ -634,13 +634,13 @@ class CommandHandler extends Observer
|
||||
|
||||
}
|
||||
|
||||
_matchCommand (commandName: string)
|
||||
private _matchCommand (commandName: string)
|
||||
{
|
||||
const [ command ] = this.client.resolver.components<Command>(commandName, 'command', true);
|
||||
return command || null;
|
||||
}
|
||||
|
||||
_generateError (invoker: InvokerWrapper<true, true>, info: ErrorParams)
|
||||
private _generateError (invoker: InvokerWrapper<true, true>, info: ErrorParams)
|
||||
{
|
||||
const messages: {[key: string]: () => object} = {
|
||||
command: () =>
|
||||
|
@ -222,8 +222,7 @@ class InvokerWrapper<InGuild extends boolean = boolean, HasCommand extends boole
|
||||
});
|
||||
}
|
||||
|
||||
async reply (content: string | ReplyOptions = {}, opts: ReplyOptions = {})
|
||||
: Promise<Message>
|
||||
async reply (content: string | ReplyOptions = {}, opts: ReplyOptions = {}) : Promise<Message>
|
||||
{
|
||||
let options = opts;
|
||||
if (typeof content === 'object')
|
||||
|
Loading…
Reference in New Issue
Block a user