forked from Galactic/galactic-bot
misc fixes n tweaks
This commit is contained in:
parent
e6bfafa4ac
commit
9646080b92
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,7 +11,6 @@ commandHash.json
|
|||||||
|
|
||||||
# Logs, duh
|
# Logs, duh
|
||||||
logs
|
logs
|
||||||
emojis.json
|
|
||||||
|
|
||||||
# API
|
# API
|
||||||
src/middleware/api
|
src/middleware/api
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
"GUILD_MESSAGES",
|
"GUILD_MESSAGES",
|
||||||
"GUILD_VOICE_STATES",
|
"GUILD_VOICE_STATES",
|
||||||
"GUILD_WEBHOOKS",
|
"GUILD_WEBHOOKS",
|
||||||
"GUILD_BANS"
|
"GUILD_BANS",
|
||||||
|
"GUILD_PRESENCES"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"invite": "https://discord.gg/49u6cHu",
|
"invite": "https://discord.gg/49u6cHu",
|
||||||
|
@ -128,14 +128,14 @@ class GuildWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get locale() {
|
get locale() {
|
||||||
return this._settings?.locale || 'en_us';
|
return this._settings?.locale || 'en_gb';
|
||||||
}
|
}
|
||||||
|
|
||||||
format(index, parameters = {}, opts = {}) {
|
format(index, parameters = {}, opts = {}) {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
code = false,
|
code = false,
|
||||||
language = this.locale || 'en_us'
|
language = this.locale || 'en_gb'
|
||||||
} = opts;
|
} = opts;
|
||||||
return this.client.localeLoader.format(language, index, parameters, code);
|
return this.client.localeLoader.format(language, index, parameters, code);
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class InteractionWrapper {
|
|||||||
format(index, parameters = {}, opts = {}) {
|
format(index, parameters = {}, opts = {}) {
|
||||||
const {
|
const {
|
||||||
code = false,
|
code = false,
|
||||||
language = this.user.locale || this.guild?.locale || 'en_us'
|
language = this.user.locale || this.guild?.locale || 'en_gb'
|
||||||
} = opts;
|
} = opts;
|
||||||
return this.client.localeLoader.format(language, index, parameters, code);
|
return this.client.localeLoader.format(language, index, parameters, code);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,8 @@ class CommandHandler extends Observer {
|
|||||||
if(!member) return { error: true };
|
if(!member) return { error: true };
|
||||||
return { error: false, value: member };
|
return { error: false, value: member };
|
||||||
},
|
},
|
||||||
USER: (user) => {
|
USER: async (user) => {
|
||||||
|
user = await this.client.users.fetch(user);
|
||||||
return { error: false, value: user };
|
return { error: false, value: user };
|
||||||
},
|
},
|
||||||
TEXT_CHANNEL: async (channel) => {
|
TEXT_CHANNEL: async (channel) => {
|
||||||
@ -263,7 +264,8 @@ class CommandHandler extends Observer {
|
|||||||
channel = await guild.resolveChannel(channel);
|
channel = await guild.resolveChannel(channel);
|
||||||
return { error: false, value: channel };
|
return { error: false, value: channel };
|
||||||
},
|
},
|
||||||
ROLE: (role) => {
|
ROLE: async (role) => {
|
||||||
|
role = await guild.roles.fetch(role);
|
||||||
return { error: false, value: role };
|
return { error: false, value: role };
|
||||||
},
|
},
|
||||||
MENTIONABLE: (mentionable) => {
|
MENTIONABLE: (mentionable) => {
|
||||||
|
@ -38,11 +38,17 @@ class SlashCommand extends Command {
|
|||||||
if (opt instanceof CommandOption) this.options.push(opt);
|
if (opt instanceof CommandOption) this.options.push(opt);
|
||||||
else if (opt.name instanceof Array) {
|
else if (opt.name instanceof Array) {
|
||||||
// Allows easy templating of subcommands that share arguments
|
// Allows easy templating of subcommands that share arguments
|
||||||
const { name: names, description, ...opts } = opt;
|
const { name: names, description, type, ...opts } = opt;
|
||||||
for (const name of names) {
|
for (const name of names) {
|
||||||
let desc = description;
|
const index = names.indexOf(name);
|
||||||
if(description instanceof Array) desc = description[names.indexOf(name)] || 'Missing description';
|
let desc = description,
|
||||||
this.options.push(new CommandOption({ name, description: desc, ...opts }));
|
_type = type;
|
||||||
|
if (description instanceof Array) desc = description[index] || 'Missing description';
|
||||||
|
if (type instanceof Array) {
|
||||||
|
_type = type[index];
|
||||||
|
if(!_type) throw new Error(`Missing type for option ${name} in command ${this.name}`);
|
||||||
|
}
|
||||||
|
this.options.push(new CommandOption({ name, type: _type, description: desc, ...opts }));
|
||||||
}
|
}
|
||||||
} else this.options.push(new CommandOption(opt));
|
} else this.options.push(new CommandOption(opt));
|
||||||
}
|
}
|
||||||
|
@ -267,6 +267,10 @@ class Util {
|
|||||||
return humaniser(seconds * 1000, { largest: 2 }) + (relative ? ' ago' : '');
|
return humaniser(seconds * 1000, { largest: 2 }) + (relative ? ' ago' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static timeAgo(seconds) {
|
||||||
|
return Util.humanise(Date.now() / 1000 - seconds, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert seconds to a human readable string representation
|
* Convert seconds to a human readable string representation
|
||||||
* @param {int} seconds
|
* @param {int} seconds
|
||||||
|
Loading…
Reference in New Issue
Block a user