1 |
import { BanOptions, CommandInteraction, Guild, GuildMember, Interaction, Message, User } from 'discord.js'; |
import { CommandInteraction, 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'; |
7 |
import getUser from '../../utils/getUser'; |
import getUser from '../../utils/getUser'; |
8 |
import History from '../../automod/History'; |
import Punishment from '../../models/Punishment'; |
|
import getMember from '../../utils/getMember'; |
|
|
import ms from 'ms'; |
|
|
import Punishment from '../../types/Punishment'; |
|
9 |
import { fetchEmoji } from '../../utils/Emoji'; |
import { fetchEmoji } from '../../utils/Emoji'; |
10 |
import PunishmentType from '../../types/PunishmentType'; |
import PunishmentType from '../../types/PunishmentType'; |
11 |
|
|
49 |
return; |
return; |
50 |
} |
} |
51 |
|
|
52 |
const warnings = await Punishment.findAll({ |
const warnings = await Punishment.find({ |
53 |
where: { |
guild_id: msg.guild!.id, |
54 |
guild_id: msg.guild!.id, |
user_id: user.id, |
55 |
user_id: user.id, |
type: PunishmentType.WARNING |
56 |
type: PunishmentType.WARNING |
}).sort({ createdAt: -1 }); |
|
}, |
|
|
}); |
|
57 |
|
|
58 |
if (warnings.length < 1) { |
if (warnings.length < 1) { |
59 |
await msg.reply({ |
await msg.reply({ |
70 |
let str = ''; |
let str = ''; |
71 |
|
|
72 |
for await (const warning of warnings) { |
for await (const warning of warnings) { |
73 |
str += `ID: ${warning.get().id}\n`; |
str += `ID: ${warning.id}\n`; |
74 |
str += `Reason: ${warning.get().reason ?? '*No reason provided*'}\n`; |
str += `Reason: ${warning.reason ?? '*No reason provided*'}\n`; |
75 |
|
|
76 |
try { |
try { |
77 |
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`; |
78 |
} |
} |
79 |
catch (e) { |
catch (e) { |
80 |
str += `Warned by: ${warning.get().mod_id}\n`; |
str += `Warned by: ${warning.mod_id}\n`; |
81 |
} |
} |
82 |
|
|
83 |
str += `Date: ${warning.get().createdAt}\n\n`; |
str += `Date: ${warning.createdAt}\n\n`; |
84 |
} |
} |
85 |
|
|
86 |
await msg.reply({ |
await msg.reply({ |
128 |
return; |
return; |
129 |
} |
} |
130 |
|
|
131 |
const warning = await Punishment.destroy({ |
const warning = await Punishment.deleteOne({ |
132 |
where: { |
guild_id: msg.guild!.id, |
133 |
guild_id: msg.guild!.id, |
user_id: user.id, |
134 |
user_id: user.id, |
type: PunishmentType.WARNING |
|
type: PunishmentType.WARNING |
|
|
}, |
|
135 |
}); |
}); |
136 |
|
|
137 |
if (warning < 1) { |
if (warning.deletedCount < 1) { |
138 |
await msg.reply({ |
await msg.reply({ |
139 |
embeds: [ |
embeds: [ |
140 |
new MessageEmbed() |
new MessageEmbed() |
168 |
return; |
return; |
169 |
} |
} |
170 |
|
|
171 |
const id = options.isInteraction ? options.options.getNumber('id') : parseInt(options.args[0]); |
const id = options.isInteraction ? options.options.getString('id') : parseInt(options.args[0]); |
172 |
|
|
173 |
const warning = await Punishment.findOne({ |
const warning = await Punishment.findOne({ |
174 |
where: { |
id, |
175 |
id, |
guild_id: msg.guild!.id, |
176 |
guild_id: msg.guild!.id, |
type: PunishmentType.WARNING |
|
type: PunishmentType.WARNING |
|
|
}, |
|
|
order: [ |
|
|
['id', 'DESC'] |
|
|
], |
|
177 |
}); |
}); |
178 |
|
|
179 |
if (!warning) { |
if (!warning) { |
188 |
return; |
return; |
189 |
} |
} |
190 |
|
|
191 |
await warning.destroy(); |
await warning.delete(); |
192 |
|
|
193 |
await msg.reply({ |
await msg.reply({ |
194 |
embeds: [ |
embeds: [ |
212 |
return; |
return; |
213 |
} |
} |
214 |
|
|
215 |
const id = options.isInteraction ? options.options.getNumber('id') : parseInt(options.args[0]); |
const id = options.isInteraction ? options.options.getString('id') : parseInt(options.args[0]); |
216 |
|
|
217 |
const warning = await Punishment.findOne({ |
const warning = await Punishment.findOne({ |
218 |
where: { |
id, |
219 |
id, |
guild_id: msg.guild!.id, |
220 |
guild_id: msg.guild!.id, |
type: PunishmentType.WARNING |
|
type: PunishmentType.WARNING |
|
|
}, |
|
|
order: [ |
|
|
['id', 'DESC'] |
|
|
], |
|
221 |
}); |
}); |
222 |
|
|
223 |
if (!warning) { |
if (!warning) { |