1 |
import { BanOptions, CommandInteraction, Guild, GuildMember, Interaction, Message, User } from 'discord.js'; |
import { CommandInteraction, 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'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
import getMember from '../../utils/getMember'; |
import getMember from '../../utils/getMember'; |
8 |
import PunishmentType from '../../types/PunishmentType'; |
import PunishmentType from '../../types/PunishmentType'; |
|
import History from '../../automod/History'; |
|
9 |
|
|
10 |
export async function warn(client: DiscordClient, user: User, reason: string | undefined, msg: Message | CommandInteraction, warned_by?: User) { |
export async function warn(client: DiscordClient, user: User, reason: string | undefined, msg: Message | CommandInteraction, warned_by?: User) { |
11 |
const { default: Punishment } = await import('../../models/Punishment'); |
const { default: Punishment } = await import('../../models/Punishment'); |
17 |
mod_id: warned_by?.id ?? msg.member!.user.id, |
mod_id: warned_by?.id ?? msg.member!.user.id, |
18 |
mod_tag: warned_by?.tag ?? (msg.member!.user as User).tag, |
mod_tag: warned_by?.tag ?? (msg.member!.user as User).tag, |
19 |
type: PunishmentType.WARNING, |
type: PunishmentType.WARNING, |
20 |
|
createdAt: new Date() |
21 |
}); |
}); |
22 |
|
|
23 |
const strike = await Punishment.count({ |
const strike = await Punishment.count({ |
24 |
where: { |
guild_id: msg.guild!.id, |
25 |
guild_id: msg.guild!.id, |
user_id: user.id, |
26 |
user_id: user.id, |
type: PunishmentType.WARNING, |
|
type: PunishmentType.WARNING, |
|
|
} |
|
27 |
}); |
}); |
28 |
|
|
29 |
// await History.create(user.id, msg.guild!, 'warn', warned_by?.id ?? msg.member!.user.id, reason ?? null); |
// await History.create(user.id, msg.guild!, 'warn', warned_by?.id ?? msg.member!.user.id, reason ?? null); |
140 |
await msg.reply({ |
await msg.reply({ |
141 |
embeds: [ |
embeds: [ |
142 |
new MessageEmbed() |
new MessageEmbed() |
143 |
.setDescription(`The user ${user.user.tag} has been warned`) |
.setDescription(`The user ${user.user.tag} has been warned` + (DMed ? "" : "\n:warning: The user has DMs disabled, so they might not know that they've been warned.")) |
144 |
.addFields([ |
.addFields([ |
145 |
{ |
{ |
146 |
name: "Reason", |
name: "Reason", |
157 |
{ |
{ |
158 |
name: "ID", |
name: "ID", |
159 |
value: warning.get('id') + '' |
value: warning.get('id') + '' |
160 |
}, |
} |
|
...(DMed ? {} : { |
|
|
name: "Note", |
|
|
value: ":warning: The user has DMs disabled, so they might not know that they've been warned." |
|
|
}) |
|
161 |
]) |
]) |
162 |
] |
] |
163 |
}); |
}); |