Migrate events to typescript

This commit is contained in:
Ethan Lane 2021-12-02 15:38:38 +00:00
parent 24818bcb44
commit 44571d735a
Signed by: Vylpes
GPG key ID: EED233CC06D12504
10 changed files with 155 additions and 142 deletions

54
src/helpers/EventEmbed.ts Normal file
View file

@ -0,0 +1,54 @@
import { MessageEmbed, TextChannel, User, Guild } from "discord.js";
import ErrorMessages from "../constants/ErrorMessages";
import ErrorEmbed from "./ErrorEmbed";
export default class EventEmbed extends MessageEmbed {
private _guild: Guild;
constructor(guild: Guild, title: string) {
super();
super.setColor(process.env.EMBED_COLOUR!);
super.setTitle(title);
this._guild = guild;
}
// 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 SendToChannel(name: string) {
const channel = this._guild.channels.cache
.find(channel => channel.name == name) as TextChannel;
if (!channel) {
console.error(`Unable to find channel ${name}`);
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!)
}
}