some bs
This commit is contained in:
parent
bbd8a390c4
commit
79e0bce3b5
@ -1,4 +1,5 @@
|
|||||||
const { Observer } = require('../../../interfaces/');
|
const { Observer } = require('../../../interfaces/');
|
||||||
|
const { Util } = require('../../../../util');
|
||||||
|
|
||||||
const CONSTANTS = {};
|
const CONSTANTS = {};
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ class UtilityHook extends Observer {
|
|||||||
this.hooks = [
|
this.hooks = [
|
||||||
['guildMemberAdd', this.welcome.bind(this)],
|
['guildMemberAdd', this.welcome.bind(this)],
|
||||||
['guildMemberAdd', this.autorole.bind(this)]
|
['guildMemberAdd', this.autorole.bind(this)]
|
||||||
]
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +33,12 @@ class UtilityHook extends Observer {
|
|||||||
const { guild } = member;
|
const { guild } = member;
|
||||||
const settings = await guild.settings();
|
const settings = await guild.settings();
|
||||||
const setting = settings.autorole;
|
const setting = settings.autorole;
|
||||||
if(!setting.enabled) return;
|
if (!setting.enabled) return;
|
||||||
|
if (!guild.me.hasPermission('MANAGE_ROLES')) return;
|
||||||
|
|
||||||
|
const _roles = await guild.resolveRoles(setting.roles);
|
||||||
|
const roles = _roles.map((r) => r.id);
|
||||||
|
await member.roles.add(roles, 'Adding autoroles').catch(this.client.logger.error);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +47,8 @@ class UtilityHook extends Observer {
|
|||||||
const { guild, user } = member;
|
const { guild, user } = member;
|
||||||
const settings = await guild.settings();
|
const settings = await guild.settings();
|
||||||
const setting = settings.welcomer;
|
const setting = settings.welcomer;
|
||||||
if(!setting.enabled) return;
|
if (!setting.enabled) return;
|
||||||
|
|
||||||
const channel = await user.createDM();
|
const channel = await user.createDM();
|
||||||
const message = this._replaceTags(setting.message, member);
|
const message = this._replaceTags(setting.message, member);
|
||||||
await channel.send(message).catch();
|
await channel.send(message).catch();
|
||||||
@ -52,13 +58,13 @@ class UtilityHook extends Observer {
|
|||||||
_replaceTags(text, member) {
|
_replaceTags(text, member) {
|
||||||
const { user, guild } = member;
|
const { user, guild } = member;
|
||||||
return text
|
return text
|
||||||
.replace(/\{mention\}/g, `<@${member.id}>`)
|
.replace(/\{mention\}/gu, `<@${member.id}>`)
|
||||||
.replace(/\{tag\}/g, Util.escapeMarkdown(user.tag))
|
.replace(/\{tag\}/gu, Util.escapeMarkdown(user.tag))
|
||||||
.replace(/\{user\}/g, Util.escapeMarkdown(user.username))
|
.replace(/\{user\}/gu, Util.escapeMarkdown(user.username))
|
||||||
.replace(/\{guildsize\}/g, guild.memberCount)
|
.replace(/\{guildsize\}/gu, guild.memberCount)
|
||||||
.replace(/\{guildname\}/g, guild.name)
|
.replace(/\{guildname\}/gu, guild.name)
|
||||||
.replace(/\{accage\}/g, this.client.resolver.timeAgo(Date.now()/1000 - user.createdTimestamp/1000)) //.replace(/a/, '1')
|
.replace(/\{accage\}/gu, this.client.resolver.timeAgo(Date.now()/1000 - user.createdTimestamp/1000)) //.replace(/a/, '1')
|
||||||
.replace(/\{id\}/g, user.id)
|
.replace(/\{id\}/gu, user.id)
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ const Message = Structures.extend('Message', (Message) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.command.showUsage && !this.parameters.length && !Object.values(this.arguments).length) {
|
if (this.command.showUsage && !this.parameters.length && !Object.values(this.arguments).length) {
|
||||||
return this._showUsage();
|
return this.embed(this.command.usageEmbed(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.emit('commandExecute', this);
|
this.client.emit('commandExecute', this);
|
||||||
|
Loading…
Reference in New Issue
Block a user