vylbot-app/src/events/MemberEvents.ts
Vylpes f61c4c728a
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>
2022-01-30 17:03:36 +00:00

49 lines
No EOL
1.5 KiB
TypeScript

import { Event } from "../type/event";
import { GuildMember } from "discord.js";
import EventEmbed from "../helpers/embeds/EventEmbed";
import GuildMemberUpdate from "./MemberEvents/GuildMemberUpdate";
import IEventReturnContext from "../contracts/IEventReturnContext";
export default class MemberEvents extends Event {
constructor() {
super();
}
public override guildMemberAdd(member: GuildMember): IEventReturnContext {
const embed = new EventEmbed(member.guild, "Member Joined");
embed.AddUser("User", member.user, true);
embed.addField("Created", member.user.createdAt);
embed.setFooter(`Id: ${member.user.id}`);
embed.SendToMemberLogsChannel();
return {
embeds: [embed]
};
}
public override guildMemberRemove(member: GuildMember): IEventReturnContext {
const embed = new EventEmbed(member.guild, "Member Left");
embed.AddUser("User", member.user, true);
embed.addField("Joined", member.joinedAt);
embed.setFooter(`Id: ${member.user.id}`);
embed.SendToMemberLogsChannel();
return {
embeds: [embed]
};
}
public override guildMemberUpdate(oldMember: GuildMember, newMember: GuildMember): IEventReturnContext {
const handler = new GuildMemberUpdate(oldMember, newMember);
if (oldMember.nickname != newMember.nickname) { // Nickname change
handler.NicknameChanged();
}
return {
embeds: []
};
}
}