1 |
|
/** |
2 |
|
* This file is part of SudoBot. |
3 |
|
* |
4 |
|
* Copyright (C) 2021-2022 OSN Inc. |
5 |
|
* |
6 |
|
* SudoBot is free software; you can redistribute it and/or modify it |
7 |
|
* under the terms of the GNU Affero General Public License as published by |
8 |
|
* the Free Software Foundation, either version 3 of the License, or |
9 |
|
* (at your option) any later version. |
10 |
|
* |
11 |
|
* SudoBot is distributed in the hope that it will be useful, but |
12 |
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
* GNU Affero General Public License for more details. |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU Affero General Public License |
17 |
|
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>. |
18 |
|
*/ |
19 |
|
|
20 |
import { ModalSubmitInteraction } from 'discord-modals'; |
import { ModalSubmitInteraction } from 'discord-modals'; |
21 |
import { PermissionResolvable, AutocompleteInteraction, CommandInteraction, CommandInteractionOption, ContextMenuInteraction, Interaction, Message, MessageEditOptions, MessageOptions, MessagePayload, WebhookEditMessageOptions, SelectMenuInteraction, ButtonInteraction, GuildMember } from 'discord.js'; |
import { PermissionResolvable, AutocompleteInteraction, CommandInteraction, ContextMenuInteraction, Interaction, Message, MessageEditOptions, MessageOptions, MessagePayload, WebhookEditMessageOptions, GuildMember } from 'discord.js'; |
22 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
23 |
import AutoCompleteOptions from '../../types/AutoCompleteOptions'; |
import AutoCompleteOptions from '../../types/AutoCompleteOptions'; |
24 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
31 |
coolDown?: number; |
coolDown?: number; |
32 |
ownerOnly: boolean = false; |
ownerOnly: boolean = false; |
33 |
permissions: PermissionResolvable[] = []; |
permissions: PermissionResolvable[] = []; |
34 |
|
|
35 |
|
|
36 |
constructor(private name: string, private category: string, private aliases: Array<string>) { |
constructor(private name: string, private category: string, private aliases: Array<string>) { |
37 |
|
|
38 |
} |
} |
39 |
|
|
40 |
getName(): string { |
getName(): string { |
41 |
return this.name; |
return this.name; |
42 |
} |
} |
43 |
|
|
44 |
getCategory(): string { |
getCategory(): string { |
45 |
return this.category; |
return this.category; |
46 |
} |
} |
47 |
|
|
48 |
getAliases(): Array<string> { |
getAliases(): Array<string> { |
49 |
return this.aliases; |
return this.aliases; |
50 |
} |
} |
51 |
|
|
52 |
|
async permissionValidation(client: DiscordClient, member: GuildMember): Promise <boolean> { |
53 |
|
return true; |
54 |
|
} |
55 |
|
|
56 |
async autoComplete(client: DiscordClient, interaction: AutocompleteInteraction, options: AutoCompleteOptions): Promise <void> { |
async autoComplete(client: DiscordClient, interaction: AutocompleteInteraction, options: AutoCompleteOptions): Promise <void> { |
57 |
|
|
107 |
} |
} |
108 |
} |
} |
109 |
|
|
110 |
|
if (!(await this.permissionValidation(client, member!))) { |
111 |
|
if (message instanceof Interaction && !message.isRepliable()) |
112 |
|
return; |
113 |
|
|
114 |
|
await message.reply({ |
115 |
|
embeds: [ |
116 |
|
{ |
117 |
|
description: ":x: You don't have enough permissions to run this command.", |
118 |
|
color: 0xf14a60 |
119 |
|
} |
120 |
|
] |
121 |
|
}); |
122 |
|
|
123 |
|
return false; |
124 |
|
} |
125 |
|
|
126 |
return true; |
return true; |
127 |
} |
} |
128 |
|
|