Feature/74 merge vylbot core (#80)

* Merge VylBot-Core

* Update commands to new system

* Fix issue where events would not load
This commit is contained in:
Vylpes 2021-12-24 14:55:28 +00:00 committed by GitHub
parent 45d871fbf7
commit 2cc12d91be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 3368 additions and 147 deletions

View file

@ -0,0 +1,19 @@
import { MessageEmbed } from "discord.js";
import { ICommandContext } from "../../contracts/ICommandContext";
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);
}
}

View file

@ -0,0 +1,52 @@
import { MessageEmbed, TextChannel, User, Guild } from "discord.js";
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!)
}
}

View file

@ -0,0 +1,60 @@
import { MessageEmbed, TextChannel, User } from "discord.js";
import ErrorMessages from "../../constants/ErrorMessages";
import { ICommandContext } from "../../contracts/ICommandContext";
import ErrorEmbed from "./ErrorEmbed";
export default class LogEmbed extends MessageEmbed {
private _context: ICommandContext;
constructor(context: ICommandContext, title: string) {
super();
super.setColor(process.env.EMBED_COLOUR!);
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.ChannelNotFound);
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,26 @@
import { MessageEmbed } from "discord.js";
import { ICommandContext } from "../../contracts/ICommandContext";
export default class PublicEmbed extends MessageEmbed {
private _context: ICommandContext;
constructor(context: ICommandContext, title: string, description: string) {
super();
super.setColor(process.env.EMBED_COLOUR!);
super.setTitle(title);
super.setDescription(description);
this._context = context;
}
// Detail methods
public AddReason(message: String) {
super.addField("Reason", message || "*none*");
}
// Send methods
public SendToCurrentChannel() {
this._context.message.channel.send(this);
}
}