forked from Galactic/galactic-bot
misc fixes
This commit is contained in:
parent
79f09fe03c
commit
8db0c0d368
@ -94,15 +94,17 @@ class ApiClientUtil {
|
||||
|
||||
const { guildId } = message;
|
||||
const evalFunc = (client, { guildId }) => {
|
||||
const guild = client.guilds.cache.get(guildId);
|
||||
if (!guild) return null;
|
||||
const wrapper = new client.wrapperClasses.GuildWrapper(client, guild);
|
||||
try {
|
||||
const wrapper = client.getGuildWrapper(guildId);
|
||||
return wrapper.toJSON();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
this.client.logger.debug(`guild-live request - shard: ${message.shard}, message id ${message.id}`);
|
||||
const result = await this.client.shardingManager.broadcastEval(evalFunc, { context: { guildId } });
|
||||
const guild = result.find((elem) => elem !== undefined);
|
||||
const guild = result.find((elem) => elem !== null);
|
||||
return guild;
|
||||
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class Logger {
|
||||
|
||||
const maximumCharacters = Math.max(...Constants.Types.map((t) => t.length));
|
||||
const spacers = maximumCharacters - type.length;
|
||||
const text = `${chalk[color](type)}${" ".repeat(spacers)} ${header} : ${string}`;
|
||||
const text = `${chalk[color](type)}${" ".repeat(spacers)} ${header}: ${string}`;
|
||||
const strippedText = text.replace(stripRegex, '');
|
||||
|
||||
console.log(text); //eslint-disable-line no-console
|
||||
|
@ -3,6 +3,7 @@ const { Routes } = require('discord-api-types/v9');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const hash = require('object-hash');
|
||||
const { inspect } = require('util');
|
||||
|
||||
class SlashCommandManager {
|
||||
|
||||
@ -43,7 +44,7 @@ class SlashCommandManager {
|
||||
this.client.logger.write('info', `Commands hash: ${cmdHash}, ${guilds.length} out of date`);
|
||||
if (!guilds.length) return;
|
||||
const promises = [];
|
||||
//console.log(JSON.stringify(commands));
|
||||
//fs.writeFileSync(path.join(process.cwd(), 'commands.json'), JSON.stringify(commands));
|
||||
for(const guild of guilds) {
|
||||
promises.push(this.rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guild),
|
||||
@ -72,6 +73,10 @@ class SlashCommandManager {
|
||||
str += `${command.name}: `;
|
||||
const options = Object.keys(invalid[key].options);
|
||||
for (const optKey of options) {
|
||||
if (!command.options[optKey]) {
|
||||
this.client.logger.warn(`Missing properties for ${command.name}: ${optKey}\nOptions: ${inspect(command.options)}`);
|
||||
continue;
|
||||
}
|
||||
str += `${command.options[optKey].name}\t`;
|
||||
}
|
||||
str += `\n\n`;
|
||||
|
@ -37,7 +37,7 @@ class RateLimiter {
|
||||
|
||||
if (!channel || !(channel instanceof TextChannel)) reject(new Error('Missing channel'));
|
||||
if (!message || !(message instanceof Message)) reject(new Error('Missing message'));
|
||||
if (!channel.permissionsFor(channel.guild.members.me).has('ManageMessages')) reject(new Error('Missing permission ManageMessages'));
|
||||
if (!channel.permissionsFor(this.client.user).has('ManageMessages')) reject(new Error('Missing permission ManageMessages'));
|
||||
|
||||
if (!this.deleteQueue[channel.id]) this.deleteQueue[channel.id] = [];
|
||||
this.deleteQueue[channel.id].push({ message, resolve, reject });
|
||||
@ -106,7 +106,7 @@ class RateLimiter {
|
||||
|
||||
if (!channel || !(channel instanceof TextChannel)) reject(new Error('Missing channel.'));
|
||||
if (!message || !message.length) reject(new Error('Missing message.'));
|
||||
if (!channel.permissionsFor(channel.guild.members.me).has('SendMessages')) reject(new Error('Missing permission SendMessages'));
|
||||
if (!channel.permissionsFor(this.client.user).has('SendMessages')) reject(new Error('Missing permission SendMessages'));
|
||||
|
||||
//Initiate queue
|
||||
if (!this.sendQueue[channel.id]) this.sendQueue[channel.id] = [];
|
||||
@ -173,7 +173,7 @@ class RateLimiter {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!channel || !(channel instanceof TextChannel)) reject(new Error('Missing channel'));
|
||||
if (!channel.permissionsFor(channel.guild.members.me).has('SendMessages')) reject(new Error('Missing permission SendMessages'));
|
||||
if (!channel.permissionsFor(this.client.user).has('SendMessages')) reject(new Error('Missing permission SendMessages'));
|
||||
if (!message) reject(new Error('Missing message'));
|
||||
if (limit === null) limit = 15;
|
||||
|
||||
|
@ -217,7 +217,7 @@ class InteractionWrapper {
|
||||
}
|
||||
|
||||
isContextMenu() {
|
||||
return this.interaction.isContextMenu();
|
||||
return this.interaction.isContextMenuCommand();
|
||||
}
|
||||
|
||||
isSelectMenu() {
|
||||
|
Loading…
Reference in New Issue
Block a user