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

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

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

revision 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 189 by rakin, Mon Jul 29 17:28:56 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, GuildMember, Interaction, Message, User } from 'discord.js';  import { BanOptions, CommandInteraction, ContextMenuInteraction, GuildMember, Interaction, Message, User } 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 getMember from '../../utils/getMe Line 9  import getMember from '../../utils/getMe
9  import History from '../../automod/History';  import History from '../../automod/History';
10  import Punishment from '../../models/Punishment';  import Punishment from '../../models/Punishment';
11  import PunishmentType from '../../types/PunishmentType';  import PunishmentType from '../../types/PunishmentType';
12    import ModerationEmbed from '../../utils/ModerationEmbed';
13    
14  export default class BeanCommand extends BaseCommand {  export default class BeanCommand extends BaseCommand {
15      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
16        supportsContextMenu: boolean = true;
17    
18      constructor() {      constructor() {
19          super('bean', 'moderation', []);          super('bean', 'moderation', ['Bean']);
20      }      }
21    
22      async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {      async run(client: DiscordClient, msg: Message | CommandInteraction | ContextMenuInteraction, options: CommandOptions | InteractionOptions) {
23          if (!options.isInteraction && typeof options.args[0] === 'undefined') {          if (!options.isInteraction && typeof options.args[0] === 'undefined') {
24              await msg.reply({              await msg.reply({
25                  embeds: [                  embeds: [
# Line 31  export default class BeanCommand extends Line 33  export default class BeanCommand extends
33          }          }
34    
35          let user: GuildMember;          let user: GuildMember;
36            let dm = true;
37          let reason: string | undefined;          let reason: string | undefined;
38    
39          if (options.isInteraction) {          if (options.isInteraction) {
40              user = await <GuildMember> options.options.getMember('member');              user = await <GuildMember> (msg instanceof ContextMenuInteraction ? options.options.getMember('user') : options.options.getMember('member'));
41    
42              if (!user) {              if (!user) {
43                  await msg.reply({                  await msg.reply({
44                      embeds: [                      embeds: [
45                          new MessageEmbed()                          new MessageEmbed()
46                          .setColor('#f14a60')                          .setColor('#f14a60')
47                          .setDescription("Invalid user given.")                          .setDescription("Invalid member given.")
48                      ]                      ]
49                  });                  });
50            
# Line 95  export default class BeanCommand extends Line 98  export default class BeanCommand extends
98    
99              await History.create(user.id, msg.guild!, 'bean', msg.member!.user.id, typeof reason === 'undefined' ? null : reason);              await History.create(user.id, msg.guild!, 'bean', msg.member!.user.id, typeof reason === 'undefined' ? null : reason);
100    
101              await user.send({              try {
102                  embeds: [                  await user.send({
103                      new MessageEmbed()                      embeds: [
104                      .setAuthor({                          new MessageEmbed()
105                          iconURL: <string> msg.guild!.iconURL(),                              .setAuthor({
106                          name: `\tYou have been beaned in ${msg.guild!.name}`                                  iconURL: <string> msg.guild!.iconURL(),
107                      })                                  name: `\tYou have been beaned in ${msg.guild!.name}`
108                      .addFields([                              })
109                          {                              .addFields([
110                              name: "Reason",                                  {
111                              value: typeof reason === 'undefined' ? '*No reason provided*' : reason                                      name: "Reason",
112                          }                                      value: typeof reason === 'undefined' ? '*No reason provided*' : reason
113                      ])                                  }
114                  ]                              ])
115              });                      ]
116                    });
117                }
118                catch (e) {
119                    console.log(e);
120                    dm = false;
121                }
122    
123              await client.logger.logBeaned(user, typeof reason === 'undefined' ? '*No reason provided*' : reason, msg.member!.user as User);              await client.logger.logBeaned(user, typeof reason === 'undefined' ? '*No reason provided*' : reason, msg.member!.user as User);
124          }          }
# Line 117  export default class BeanCommand extends Line 126  export default class BeanCommand extends
126              console.log(e);                          console.log(e);            
127          }          }
128    
129          await msg.reply({          /*await msg.reply({
130              embeds: [              embeds: [
131                  new MessageEmbed()                  new MessageEmbed()
132                  .setAuthor({                  .setAuthor({
133                      name: user.user.tag,                      name: user.user.tag,
134                      iconURL: user.user.displayAvatarURL(),                      iconURL: user.user.displayAvatarURL(),
135                  })                  })
136                  .setDescription(user.user.tag + " has been beaned.")                  .setDescription(user.user.tag + " has been beaned." + (!dm ? "\nThey have DMs disabled. They will not know that they have been beaned." : ''))
137                  .addFields([                  .addFields([
138                      {                      {
139                          name: "Beaned by",                          name: "Beaned by",
# Line 136  export default class BeanCommand extends Line 145  export default class BeanCommand extends
145                      }                      }
146                  ])                  ])
147              ]              ]
148            });*/
149    
150            await msg.reply({
151                embeds: [
152                    new ModerationEmbed(user, msg.member!.user, {
153                        description: `${user.tag} has been beaned.`
154                    })
155                    .setReason(reason)
156                ]
157          });          });
158      }      }
 }  
159    }

Legend:
Removed from v.86  
changed lines
  Added in v.189

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26