Migrate ban command

This commit is contained in:
Ethan Lane 2021-11-29 11:27:44 +00:00
parent bb433749f8
commit ecf9c5e4fc
Signed by: Vylpes
GPG key ID: EED233CC06D12504
8 changed files with 183 additions and 96 deletions

19
src/helpers/ErrorEmbed.ts Normal file
View file

@ -0,0 +1,19 @@
import { MessageEmbed } from "discord.js";
import { ICommandContext } from "vylbot-core";
export default class ErrorEmbed extends MessageEmbed {
private _context: ICommandContext;
constructor(context: ICommandContext, message: String) {
super();
super.setColor(process.env.EMBED_COLOUR_ERROR!);
super.setDescription(message);
this._context = context;
}
public SendToCurrentChannel() {
this._context.message.channel.send(this);
}
}

60
src/helpers/LogEmbed.ts Normal file
View file

@ -0,0 +1,60 @@
import { MessageEmbed, TextChannel, User } from "discord.js";
import { ICommandContext } from "vylbot-core";
import ErrorMessages from "../constants/ErrorMessages";
import ErrorEmbed from "./ErrorEmbed";
export default class LogEmbed extends MessageEmbed {
private _context: ICommandContext;
constructor(context: ICommandContext, title: string) {
super();
super.setColor(process.env.ERROR_EMBED!);
super.setTitle(title);
this._context = context;
}
// Detail methods
public AddUser(title: string, user: User, setThumbnail: boolean = false) {
super.addField(title, `${user} \`${user.tag}\``, true);
if (setThumbnail) {
super.setThumbnail(user.displayAvatarURL());
}
}
public AddReason(message: String) {
super.addField("Reason", message || "*none*");
}
// Send methods
public SendToCurrentChannel() {
this._context.message.channel.send(this);
}
public SendToChannel(name: string) {
const channel = this._context.message.guild?.channels.cache
.find(channel => channel.name == name) as TextChannel;
if (!channel) {
const errorEmbed = new ErrorEmbed(this._context, ErrorMessages.CantFindChannel);
errorEmbed.SendToCurrentChannel();
return;
}
channel.send(this);
}
public SendToMessageLogsChannel() {
this.SendToChannel(process.env.CHANNELS_LOGS_MESSAGE!)
}
public SendToMemberLogsChannel() {
this.SendToChannel(process.env.CHANNELS_LOGS_MEMBER!)
}
public SendToModLogsChannel() {
this.SendToChannel(process.env.CHANNELS_LOGS_MOD!)
}
}

View file

@ -0,0 +1,21 @@
import { MessageEmbed } from "discord.js";
import { ICommandContext } from "vylbot-core";
export default class PublicEmbed extends MessageEmbed {
private _context: ICommandContext;
constructor(context: ICommandContext, title: string, description: string) {
super();
super.setColor(process.env.ERROR_EMBED!);
super.setTitle(title);
super.setDescription(description);
this._context = context;
}
// Send methods
public SendToCurrentChannel() {
this._context.message.channel.send(this);
}
}