Migrate warn command
This commit is contained in:
parent
4ff88d0694
commit
c62488aa63
2 changed files with 53 additions and 86 deletions
53
src/commands/warn.ts
Normal file
53
src/commands/warn.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
import { Command, ICommandContext } from "vylbot-core";
|
||||
import ErrorEmbed from "../helpers/ErrorEmbed";
|
||||
import LogEmbed from "../helpers/LogEmbed";
|
||||
import PublicEmbed from "../helpers/PublicEmbed";
|
||||
|
||||
export default class Warn extends Command {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
super._category = "Moderation";
|
||||
super._roles = [
|
||||
process.env.ROLES_MODERATOR!
|
||||
];
|
||||
}
|
||||
|
||||
public override execute(context: ICommandContext) {
|
||||
const user = context.message.mentions.users.first();
|
||||
|
||||
if (!user) {
|
||||
const errorEmbed = new ErrorEmbed(context, "Please specify a valid user");
|
||||
errorEmbed.SendToCurrentChannel();
|
||||
return;
|
||||
}
|
||||
|
||||
const member = context.message.guild?.member(user);
|
||||
|
||||
if (!member) {
|
||||
const errorEmbed = new ErrorEmbed(context, "Please specify a valid user");
|
||||
errorEmbed.SendToCurrentChannel();
|
||||
return;
|
||||
}
|
||||
|
||||
const reasonArgs = context.args;
|
||||
reasonArgs.splice(0, 1);
|
||||
|
||||
const reason = reasonArgs.join(" ");
|
||||
|
||||
if (!context.message.guild?.available) {
|
||||
return;
|
||||
}
|
||||
|
||||
const logEmbed = new LogEmbed(context, "Member Warned");
|
||||
logEmbed.AddUser("User", user, true);
|
||||
logEmbed.AddUser("Moderator", context.message.author);
|
||||
logEmbed.AddReason(reason);
|
||||
|
||||
const publicEmbed = new PublicEmbed(context, "", `${user} has been warned`);
|
||||
publicEmbed.AddReason(reason);
|
||||
|
||||
logEmbed.SendToModLogsChannel();
|
||||
publicEmbed.SendToCurrentChannel();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue