forked from Galactic/galactic-bot
welcomer and start for autorole
This commit is contained in:
parent
46b374f2bb
commit
57dad51b5c
67
structure/client/components/observers/UtilityHook.js
Normal file
67
structure/client/components/observers/UtilityHook.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
const { Observer } = require('../../../interfaces/');
|
||||||
|
|
||||||
|
const CONSTANTS = {};
|
||||||
|
|
||||||
|
class UtilityHook extends Observer {
|
||||||
|
|
||||||
|
constructor(client) {
|
||||||
|
|
||||||
|
super(client, {
|
||||||
|
name: 'utility',
|
||||||
|
priority: 3
|
||||||
|
});
|
||||||
|
|
||||||
|
this.hooks = [
|
||||||
|
['guildMemberAdd', this.welcome.bind(this)],
|
||||||
|
['guildMemberAdd', this.autorole.bind(this)]
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async stickyRole(member) {
|
||||||
|
|
||||||
|
const { guild } = member;
|
||||||
|
const settings = await guild.settings();
|
||||||
|
const setting = settings.stickyRole;
|
||||||
|
if(!setting.enabled) return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async autorole(member) {
|
||||||
|
|
||||||
|
const { guild } = member;
|
||||||
|
const settings = await guild.settings();
|
||||||
|
const setting = settings.autorole;
|
||||||
|
if(!setting.enabled) return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async welcome(member) {
|
||||||
|
|
||||||
|
const { guild, user } = member;
|
||||||
|
const settings = await guild.settings();
|
||||||
|
const setting = settings.welcomer;
|
||||||
|
if(!setting.enabled) return;
|
||||||
|
|
||||||
|
const channel = await user.createDM();
|
||||||
|
const message = this._replaceTags(setting.message, member);
|
||||||
|
await channel.send(message).catch();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_replaceTags(text, member) {
|
||||||
|
const { user, guild } = member;
|
||||||
|
return text
|
||||||
|
.replace(/\{mention\}/g, `<@${member.id}>`)
|
||||||
|
.replace(/\{tag\}/g, Util.escapeMarkdown(user.tag))
|
||||||
|
.replace(/\{user\}/g, Util.escapeMarkdown(user.username))
|
||||||
|
.replace(/\{guildsize\}/g, guild.memberCount)
|
||||||
|
.replace(/\{guildname\}/g, guild.name)
|
||||||
|
.replace(/\{accage\}/g, this.client.resolver.timeAgo(Date.now()/1000 - user.createdTimestamp/1000)) //.replace(/a/, '1')
|
||||||
|
.replace(/\{id\}/g, user.id)
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = UtilityHook;
|
Loading…
Reference in New Issue
Block a user