/[sudobot]/trunk/src/commands/moderation/SetChPermsCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/moderation/SetChPermsCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 63 by rakin, Mon Jul 29 17:28:26 2024 UTC revision 64 by rakin, Mon Jul 29 17:28:27 2024 UTC
# Line 1  Line 1 
1  import { CategoryChannel, CommandInteraction, Message, TextChannel, Permissions, PermissionFlags, PermissionString, GuildChannel, Role } from 'discord.js';  import { CategoryChannel, CommandInteraction, Message, TextChannel, Permissions, PermissionFlags, PermissionString, GuildChannel, Role, AutocompleteInteraction, Interaction, Collection } from 'discord.js';
2  import BaseCommand from '../../utils/structures/BaseCommand';  import BaseCommand from '../../utils/structures/BaseCommand';
3  import DiscordClient from '../../client/Client';  import DiscordClient from '../../client/Client';
4  import CommandOptions from '../../types/CommandOptions';  import CommandOptions from '../../types/CommandOptions';
# Line 9  import History from '../../automod/Histo Line 9  import History from '../../automod/Histo
9  import { fetchEmoji } from '../../utils/Emoji';  import { fetchEmoji } from '../../utils/Emoji';
10  import getRole, { getRoleRaw } from '../../utils/getRole';  import getRole, { getRoleRaw } from '../../utils/getRole';
11  import { channelMention } from '@discordjs/builders';  import { channelMention } from '@discordjs/builders';
12    import AutoCompleteOptions from '../../types/AutoCompleteOptions';
13    
14  export default class BanCommand extends BaseCommand {  export default class SetChPermsCommand extends BaseCommand {
15      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
16    
17      constructor() {      constructor() {
18          super('setchperms', 'moderation', []);          super('setchperms', 'moderation', []);
19      }      }
20    
21      async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {      async autoComplete(client: DiscordClient, interaction: AutocompleteInteraction, options: AutoCompleteOptions) {
22            if (interaction.commandName === this.getName()) {
23                const focused = interaction.options.getFocused(true);
24    
25                console.log(focused);            
26    
27                if (focused.name === 'permission') {
28                    const { FLAGS } = Permissions;
29                    const responseArray = [];
30                    const perms: (keyof typeof FLAGS)[] = [
31                        'SEND_MESSAGES',
32                        'ATTACH_FILES',
33                        'EMBED_LINKS',
34                        'MANAGE_MESSAGES',
35                        'MENTION_EVERYONE',
36                        'USE_APPLICATION_COMMANDS',
37                        'USE_EXTERNAL_EMOJIS',
38                        'USE_EXTERNAL_STICKERS'
39                    ];
40    
41                    for await (const key of perms) {
42                        if (key.includes(focused.value.toString())) {
43                            responseArray.push({
44                                name: key,
45                                value: key
46                            });
47                        }
48                    }
49    
50                    console.log(responseArray);                
51    
52                    await interaction.respond(responseArray);
53                }
54            }
55        }
56    
57        async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {        
58          if (!options.isInteraction && typeof options.args[3] === 'undefined') {          if (!options.isInteraction && typeof options.args[3] === 'undefined') {
59              await msg.reply({              await msg.reply({
60                  embeds: [                  embeds: [
# Line 60  export default class BanCommand extends Line 97  export default class BanCommand extends
97    
98                  return;                  return;
99              }              }
100                else if (channels[0].type === 'GUILD_CATEGORY') {
101                    const ch = channels[0];
102                    channels = [];
103    
104                    const matching = <Collection<string, TextChannel>> await msg.guild!.channels.cache.filter(c => c.parent?.id === ch.id && c.type === 'GUILD_TEXT');
105                    channels = matching.toJSON();
106                }
107    
108              permKey = <PermissionString> options.options.getString('permission');              permKey = <PermissionString> options.options.getString('permission');
109                            

Legend:
Removed from v.63  
changed lines
  Added in v.64

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26