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

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

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

revision 335 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 336 by rakin, Mon Jul 29 17:29:36 2024 UTC
# Line 52  export default class WarningCommand exte Line 52  export default class WarningCommand exte
52              return;              return;
53          }          }
54    
55          const warnings = await Punishment.findAll({          const warnings = await Punishment.find({
56              where: {              guild_id: msg.guild!.id,
57                  guild_id: msg.guild!.id,              user_id: user.id,
58                  user_id: user.id,              type: PunishmentType.WARNING
59                  type: PunishmentType.WARNING          }).sort({ createdAt: -1 });
             },  
         });  
60    
61          if (warnings.length < 1) {          if (warnings.length < 1) {
62              await msg.reply({              await msg.reply({
# Line 75  export default class WarningCommand exte Line 73  export default class WarningCommand exte
73          let str = '';          let str = '';
74    
75          for await (const warning of warnings) {          for await (const warning of warnings) {
76              str += `ID: ${warning.get().id}\n`;              str += `ID: ${warning.id}\n`;
77              str += `Reason: ${warning.get().reason ?? '*No reason provided*'}\n`;              str += `Reason: ${warning.reason ?? '*No reason provided*'}\n`;
78    
79              try {              try {
80                  str += `Warned by: ${(await client.users.fetch(warning.get().mod_id)).tag}\n`;                  str += `Warned by: ${(await client.users.fetch(warning.mod_id)).tag}\n`;
81              }              }
82              catch (e) {              catch (e) {
83                  str += `Warned by: ${warning.get().mod_id}\n`;                  str += `Warned by: ${warning.mod_id}\n`;
84              }              }
85                            
86              str += `Date: ${warning.get().createdAt}\n\n`;              str += `Date: ${warning.createdAt}\n\n`;
87          }          }
88    
89          await msg.reply({          await msg.reply({
# Line 133  export default class WarningCommand exte Line 131  export default class WarningCommand exte
131              return;              return;
132          }          }
133    
134          const warning = await Punishment.destroy({          const warning = await Punishment.deleteOne({
135              where: {              guild_id: msg.guild!.id,
136                  guild_id: msg.guild!.id,              user_id: user.id,
137                  user_id: user.id,              type: PunishmentType.WARNING
                 type: PunishmentType.WARNING  
             },  
138          });          });
139    
140          if (warning < 1) {          if (warning.deletedCount < 1) {
141              await msg.reply({              await msg.reply({
142                  embeds: [                  embeds: [
143                      new MessageEmbed()                      new MessageEmbed()
# Line 175  export default class WarningCommand exte Line 171  export default class WarningCommand exte
171              return;              return;
172          }          }
173    
174          const id = options.isInteraction ? options.options.getNumber('id') : parseInt(options.args[0]);          const id = options.isInteraction ? options.options.getString('id') : parseInt(options.args[0]);
175    
176          const warning = await Punishment.findOne({          const warning = await Punishment.findOne({
177              where: {              id,
178                  id,              guild_id: msg.guild!.id,
179                  guild_id: msg.guild!.id,              type: PunishmentType.WARNING
                 type: PunishmentType.WARNING  
             },  
             order: [  
                 ['id', 'DESC']  
             ],  
180          });          });
181    
182          if (!warning) {          if (!warning) {
# Line 200  export default class WarningCommand exte Line 191  export default class WarningCommand exte
191              return;              return;
192          }          }
193    
194          await warning.destroy();          await warning.delete();
195    
196          await msg.reply({          await msg.reply({
197              embeds: [              embeds: [
# Line 224  export default class WarningCommand exte Line 215  export default class WarningCommand exte
215              return;              return;
216          }          }
217    
218          const id = options.isInteraction ? options.options.getNumber('id') : parseInt(options.args[0]);          const id = options.isInteraction ? options.options.getString('id') : parseInt(options.args[0]);
219    
220          const warning = await Punishment.findOne({          const warning = await Punishment.findOne({
221              where: {              id,
222                  id,              guild_id: msg.guild!.id,
223                  guild_id: msg.guild!.id,              type: PunishmentType.WARNING
                 type: PunishmentType.WARNING  
             },  
             order: [  
                 ['id', 'DESC']  
             ],  
224          });          });
225    
226          if (!warning) {          if (!warning) {

Legend:
Removed from v.335  
changed lines
  Added in v.336

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26