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); |