Feature/12 create tests (#102)

* Fix tests

* Update coverage

* Remove unrequired mock files

* Add about command test

* Update about tests

* Ban command tests

* eval command tests

* Start help command tests

* Add help command tests

* Add kick command tests

* Mute command tests

* Poll command tests

* Add role command tests

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add rules command tests

* Add unmute command tests

* Add warn command tests

* Add MemberEvents tests

* Add GuildMemberUpdate tests

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add MessageEvents tests

* Add StringTools test

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add embed tests

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Add GitHub Actions

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Move to tslint

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Remove tslint

Signed-off-by: Ethan Lane <ethan@vylpes.com>

* Remove linting script

Signed-off-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
Vylpes 2022-01-30 17:03:36 +00:00 committed by GitHub
parent 2cc12d91be
commit f61c4c728a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 6749 additions and 833 deletions

View file

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

View file

@ -1,7 +1,7 @@
import { MessageEmbed, TextChannel, User, Guild } from "discord.js";
export default class EventEmbed extends MessageEmbed {
private _guild: Guild;
public guild: Guild;
constructor(guild: Guild, title: string) {
super();
@ -9,25 +9,25 @@ export default class EventEmbed extends MessageEmbed {
super.setColor(process.env.EMBED_COLOUR!);
super.setTitle(title);
this._guild = guild;
this.guild = guild;
}
// Detail methods
public AddUser(title: string, user: User, setThumbnail: boolean = false) {
super.addField(title, `${user} \`${user.tag}\``, true);
this.addField(title, `${user} \`${user.tag}\``, true);
if (setThumbnail) {
super.setThumbnail(user.displayAvatarURL());
this.setThumbnail(user.displayAvatarURL());
}
}
public AddReason(message: String) {
super.addField("Reason", message || "*none*");
this.addField("Reason", message || "*none*");
}
// Send methods
public SendToChannel(name: string) {
const channel = this._guild.channels.cache
const channel = this.guild.channels.cache
.find(channel => channel.name == name) as TextChannel;
if (!channel) {

View file

@ -4,7 +4,7 @@ import { ICommandContext } from "../../contracts/ICommandContext";
import ErrorEmbed from "./ErrorEmbed";
export default class LogEmbed extends MessageEmbed {
private _context: ICommandContext;
public context: ICommandContext;
constructor(context: ICommandContext, title: string) {
super();
@ -12,33 +12,33 @@ export default class LogEmbed extends MessageEmbed {
super.setColor(process.env.EMBED_COLOUR!);
super.setTitle(title);
this._context = context;
this.context = context;
}
// Detail methods
public AddUser(title: string, user: User, setThumbnail: boolean = false) {
super.addField(title, `${user} \`${user.tag}\``, true);
this.addField(title, `${user} \`${user.tag}\``, true);
if (setThumbnail) {
super.setThumbnail(user.displayAvatarURL());
this.setThumbnail(user.displayAvatarURL());
}
}
public AddReason(message: String) {
super.addField("Reason", message || "*none*");
this.addField("Reason", message || "*none*");
}
// Send methods
public SendToCurrentChannel() {
this._context.message.channel.send(this);
this.context.message.channel.send(this);
}
public SendToChannel(name: string) {
const channel = this._context.message.guild?.channels.cache
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);
const errorEmbed = new ErrorEmbed(this.context, ErrorMessages.ChannelNotFound);
errorEmbed.SendToCurrentChannel();
return;
}

View file

@ -2,7 +2,7 @@ import { MessageEmbed } from "discord.js";
import { ICommandContext } from "../../contracts/ICommandContext";
export default class PublicEmbed extends MessageEmbed {
private _context: ICommandContext;
public context: ICommandContext;
constructor(context: ICommandContext, title: string, description: string) {
super();
@ -11,16 +11,16 @@ export default class PublicEmbed extends MessageEmbed {
super.setTitle(title);
super.setDescription(description);
this._context = context;
this.context = context;
}
// Detail methods
public AddReason(message: String) {
super.addField("Reason", message || "*none*");
this.addField("Reason", message || "*none*");
}
// Send methods
public SendToCurrentChannel() {
this._context.message.channel.send(this);
this.context.message.channel.send(this);
}
}