/[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 125 by rakin, Mon Jul 29 17:28:41 2024 UTC trunk/src/commands/moderation/ShotCommand.ts revision 391 by rakin, Mon Jul 29 17:29:56 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';
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 32  export default class BeanCommand extends Line 30  export default class BeanCommand extends
30          }          }
31    
32          let user: GuildMember;          let user: GuildMember;
33            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 84  export default class BeanCommand extends Line 83  export default class BeanCommand extends
83              }              }
84          }          }
85    
86            if (user.id === client.user?.id) {
87                await msg.reply({
88                    content: "Oh no no no... wait wait, you can't just do that with me!?!? Can you?",
89                    files: ['https://tenor.com/view/are-you-even-capable-vera-bennett-wentworth-can-you-handle-this-are-you-qualified-gif-22892513.gif']
90                });
91    
92                return;
93            }
94    
95            const anonymous = options.isInteraction ? options.options.getBoolean('anonymous') ?? false : false;
96    
97          try {                      try {            
98              await Punishment.create({              await Punishment.create({
99                  type: PunishmentType.BEAN,                  type: PunishmentType.SHOT,
100                  user_id: user.id,                  user_id: user.id,
101                  guild_id: msg.guild!.id,                  guild_id: msg.guild!.id,
102                  mod_id: msg.member!.user.id,                  mod_id: msg.member!.user.id,
103                  mod_tag: (msg.member!.user as User).tag,                  mod_tag: (msg.member!.user as User).tag,
104                  reason                  reason,
105                    createdAt: new Date()
106              });              });
107    
108              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);
109    
110              await user.send({              try {
111                  embeds: [                  await user.send({
112                      new MessageEmbed()                      embeds: [
113                      .setAuthor({                          new MessageEmbed()
114                          iconURL: <string> msg.guild!.iconURL(),                              .setAuthor({
115                          name: `\tYou have been beaned in ${msg.guild!.name}`                                  iconURL: <string> msg.guild!.iconURL(),
116                      })                                  name: `\tYou got a shot in ${msg.guild!.name}`
117                      .addFields([                              })
118                          {                              .addFields([
119                              name: "Reason",                                  {
120                              value: typeof reason === 'undefined' ? '*No reason provided*' : reason                                      name: "Reason",
121                          }                                      value: typeof reason === 'undefined' ? '*No reason provided*' : reason
122                      ])                                  },
123                  ]                                  ...(!anonymous ? [{
124              });                                      name: "💉 Doctor",
125                                        value: `${(msg.member?.user as User).tag}`
126                                    }] : [])
127                                ])
128                        ]
129                    });
130                }
131                catch (e) {
132                    console.log(e);
133                    dm = false;
134                }
135    
136              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);
137          }          }
138          catch (e) {          catch (e) {
139              console.log(e);                          console.log(e);            
# Line 125  export default class BeanCommand extends Line 146  export default class BeanCommand extends
146                      name: user.user.tag,                      name: user.user.tag,
147                      iconURL: user.user.displayAvatarURL(),                      iconURL: user.user.displayAvatarURL(),
148                  })                  })
149                  .setDescription(user.user.tag + " has been beaned.")                  .setDescription(user.user.tag + " got a shot." + (!dm ? "\nThey have DMs disabled. They will not know that they got a shot." : ''))
150                  .addFields([                  .addFields([
151                      {                      {
152                          name: "Beaned by",                          name: "💉 Doctor",
153                          value: (msg.member!.user as User).tag                          value: (msg.member!.user as User).tag
154                      },                      },
155                      {                      {
# Line 139  export default class BeanCommand extends Line 160  export default class BeanCommand extends
160              ]              ]
161          });          });
162      }      }
 }  
163    }

Legend:
Removed from v.125  
changed lines
  Added in v.391

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26