/[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

trunk/src/commands/moderation/BeanCommand.ts revision 189 by rakin, Mon Jul 29 17:28:56 2024 UTC trunk/src/commands/moderation/ShotCommand.ts revision 363 by rakin, Mon Jul 29 17:29:47 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, ContextMenuInteraction, GuildMember, Interaction, Message, User } from 'discord.js';  import { CommandInteraction, ContextMenuInteraction, GuildMember, 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';
5  import InteractionOptions from '../../types/InteractionOptions';  import InteractionOptions from '../../types/InteractionOptions';
6  import MessageEmbed from '../../client/MessageEmbed';  import MessageEmbed from '../../client/MessageEmbed';
 import getUser from '../../utils/getUser';  
7  import getMember from '../../utils/getMember';  import getMember from '../../utils/getMember';
 import History from '../../automod/History';  
8  import Punishment from '../../models/Punishment';  import Punishment from '../../models/Punishment';
9  import PunishmentType from '../../types/PunishmentType';  import PunishmentType from '../../types/PunishmentType';
 import ModerationEmbed from '../../utils/ModerationEmbed';  
10    
11  export default class BeanCommand extends BaseCommand {  export default class ShotCommand extends BaseCommand {
12      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
13      supportsContextMenu: boolean = true;      supportsContextMenu: boolean = true;
14    
15      constructor() {      constructor() {
16          super('bean', 'moderation', ['Bean']);          super('shot', 'moderation', ['Shot']);
17      }      }
18    
19      async run(client: DiscordClient, msg: Message | CommandInteraction | ContextMenuInteraction, options: CommandOptions | InteractionOptions) {      async run(client: DiscordClient, msg: Message | CommandInteraction | ContextMenuInteraction, options: CommandOptions | InteractionOptions) {
# Line 35  export default class BeanCommand extends Line 32  export default class BeanCommand extends
32          let user: GuildMember;          let user: GuildMember;
33          let dm = true;          let dm = true;
34          let reason: string | undefined;          let reason: string | undefined;
35            
36          if (options.isInteraction) {          if (options.isInteraction) {
37              user = await <GuildMember> (msg instanceof ContextMenuInteraction ? options.options.getMember('user') : options.options.getMember('member'));              user = await <GuildMember> (msg instanceof ContextMenuInteraction ? options.options.getMember('user') : options.options.getMember('member'));
38    
# Line 86  export default class BeanCommand extends Line 83  export default class BeanCommand extends
83              }              }
84          }          }
85    
86            const anonymous = options.isInteraction ? options.options.getBoolean('anonymous') ?? false : false;
87    
88          try {                      try {            
89              await Punishment.create({              await Punishment.create({
90                  type: PunishmentType.BEAN,                  type: PunishmentType.SHOT,
91                  user_id: user.id,                  user_id: user.id,
92                  guild_id: msg.guild!.id,                  guild_id: msg.guild!.id,
93                  mod_id: msg.member!.user.id,                  mod_id: msg.member!.user.id,
94                  mod_tag: (msg.member!.user as User).tag,                  mod_tag: (msg.member!.user as User).tag,
95                  reason                  reason,
96                    createdAt: new Date()
97              });              });
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              try {              try {
102                  await user.send({                  await user.send({
# Line 104  export default class BeanCommand extends Line 104  export default class BeanCommand extends
104                          new MessageEmbed()                          new MessageEmbed()
105                              .setAuthor({                              .setAuthor({
106                                  iconURL: <string> msg.guild!.iconURL(),                                  iconURL: <string> msg.guild!.iconURL(),
107                                  name: `\tYou have been beaned in ${msg.guild!.name}`                                  name: `\tYou got a shot in ${msg.guild!.name}`
108                              })                              })
109                              .addFields([                              .addFields([
110                                  {                                  {
111                                      name: "Reason",                                      name: "Reason",
112                                      value: typeof reason === 'undefined' ? '*No reason provided*' : reason                                      value: typeof reason === 'undefined' ? '*No reason provided*' : reason
113                                  }                                  },
114                                    ...(!anonymous ? [{
115                                        name: "💉 Doctor",
116                                        value: `${(msg.member?.user as User).tag}`
117                                    }] : [])
118                              ])                              ])
119                      ]                      ]
120                  });                  });
# Line 120  export default class BeanCommand extends Line 124  export default class BeanCommand extends
124                  dm = false;                  dm = false;
125              }              }
126    
127              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);
128          }          }
129          catch (e) {          catch (e) {
130              console.log(e);                          console.log(e);            
131          }          }
132    
133          /*await msg.reply({          await msg.reply({
134              embeds: [              embeds: [
135                  new MessageEmbed()                  new MessageEmbed()
136                  .setAuthor({                  .setAuthor({
137                      name: user.user.tag,                      name: user.user.tag,
138                      iconURL: user.user.displayAvatarURL(),                      iconURL: user.user.displayAvatarURL(),
139                  })                  })
140                  .setDescription(user.user.tag + " has been beaned." + (!dm ? "\nThey have DMs disabled. They will not know that they have been beaned." : ''))                  .setDescription(user.user.tag + " got a shot." + (!dm ? "\nThey have DMs disabled. They will not know that they got a shot." : ''))
141                  .addFields([                  .addFields([
142                      {                      {
143                          name: "Beaned by",                          name: "💉 Doctor",
144                          value: (msg.member!.user as User).tag                          value: (msg.member!.user as User).tag
145                      },                      },
146                      {                      {
# Line 145  export default class BeanCommand extends Line 149  export default class BeanCommand extends
149                      }                      }
150                  ])                  ])
151              ]              ]
         });*/  
   
         await msg.reply({  
             embeds: [  
                 new ModerationEmbed(user, msg.member!.user, {  
                     description: `${user.tag} has been beaned.`  
                 })  
                 .setReason(reason)  
             ]  
152          });          });
153      }      }
154  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26