misc fixes
This commit is contained in:
parent
e57948051b
commit
88e0ef6825
@ -1,5 +1,5 @@
|
|||||||
const { EventEmitter } = require('events');
|
const { EventEmitter } = require('events');
|
||||||
const { InteractionWrapper } = require('./wrappers');
|
const { InteractionWrapper, GuildWrapper } = require('./wrappers');
|
||||||
|
|
||||||
class EventHooker {
|
class EventHooker {
|
||||||
|
|
||||||
@ -35,10 +35,13 @@ class EventHooker {
|
|||||||
async _handleEvent(eventName) {
|
async _handleEvent(eventName) {
|
||||||
this.target.on(eventName, async (...args) => {
|
this.target.on(eventName, async (...args) => {
|
||||||
// Should probably move this elsewhere, but testing this out
|
// Should probably move this elsewhere, but testing this out
|
||||||
if (eventName === 'interactionCreate') args[0] = new InteractionWrapper(this.target, args[0], args[0].guild);
|
for (const arg of args) if (arg?.guild) arg.guildWrapper = new GuildWrapper(this.target, arg.guild);
|
||||||
|
|
||||||
|
if (eventName === 'interactionCreate') args[0] = new InteractionWrapper(this.target, args[0]);
|
||||||
|
|
||||||
// async-await does nothing in a .forEach loop,
|
// async-await does nothing in a .forEach loop,
|
||||||
// the forEach implementation does not await the results of the function before moving onto the next iteration
|
// the forEach implementation does not await the results of the function before moving onto the next iteration
|
||||||
|
// which is a problem if we don't want functionality to be overlapping, i.e. different filters trying to delete the same message
|
||||||
for (const handler of this.events.get(eventName)) {
|
for (const handler of this.events.get(eventName)) {
|
||||||
await handler(...args);
|
await handler(...args);
|
||||||
}
|
}
|
||||||
|
@ -197,6 +197,10 @@ class GuildWrapper {
|
|||||||
return this.guild.roles;
|
return this.guild.roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get premiumTier() {
|
||||||
|
return this.guild.premiumTier;
|
||||||
|
}
|
||||||
|
|
||||||
// Primarily used by the API
|
// Primarily used by the API
|
||||||
toJSON() {
|
toJSON() {
|
||||||
const json = this.guild.toJSON();
|
const json = this.guild.toJSON();
|
||||||
|
@ -14,7 +14,7 @@ class InteractionWrapper {
|
|||||||
this.client = client;
|
this.client = client;
|
||||||
this.interaction = interaction;
|
this.interaction = interaction;
|
||||||
this.command = null;
|
this.command = null;
|
||||||
this.guild = guildWrapper;
|
this.guild = guildWrapper || interaction.guildWrapper || interaction.guild;
|
||||||
|
|
||||||
// this.options = [];
|
// this.options = [];
|
||||||
|
|
||||||
|
@ -132,17 +132,17 @@ class MessageLog extends Setting {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'GENERAL_STATUS',
|
name: 'GENERAL_STATUS',
|
||||||
value: guild.format('SETTING_STATE', { bool: Boolean(setting.channel) }, { code: true }),
|
value: guild.format('GENERAL_STATE', { bool: Boolean(setting.channel) }, { code: true }),
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'GENERAL_CHANNEL',
|
name: 'GENERAL_CHANNEL',
|
||||||
value: `<#${setting.channel}>` || '`N/A`',
|
value: setting.channel ? `<#${setting.channel}>` : '`N/A`',
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ATTACHMENT_LOGS',
|
name: 'ATTACHMENT_LOGS',
|
||||||
value: guild.format('SETTING_STATE', { bool: Boolean(setting.attachments) }, { code: true }),
|
value: guild.format('GENERAL_STATE', { bool: Boolean(setting.attachments) }, { code: true }),
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user