forked from Galactic/galactic-bot
bugfixes
This commit is contained in:
parent
722b514cef
commit
482a38a80b
@ -144,3 +144,7 @@ Successfully removed all your selfroles.
|
||||
[COMMAND_SELFROLE_INVALID]
|
||||
{emoji_failure} The following roles are not self-assignable:
|
||||
**{roles}**
|
||||
|
||||
[COMMAND_SELFROLE_TOOHIGH]
|
||||
{emoji_failure} The following roles are too high for the bot to manage:
|
||||
**{roles}**
|
@ -34,12 +34,16 @@ class SelfroleCommand extends SlashCommand {
|
||||
const { guild, member } = invoker;
|
||||
const { selfrole } = await guild.settings();
|
||||
if (!selfrole.roles.length) return { index: 'COMMAND_SELFROLE_NONE', emoji: 'failure' };
|
||||
const ownHighest = guild.me.roles.highest;
|
||||
|
||||
const memberRoles = member.roles.cache.map((r) => r.id);
|
||||
const tooHigh = roles?.value.filter((r) => r.position > ownHighest.position);
|
||||
const invalid = roles?.value.filter((r) => !selfrole.roles.includes(r.id)) || [];
|
||||
const _roles = roles?.value.filter((r) => selfrole.roles.includes(r.id)) || [];
|
||||
let warning = null;
|
||||
if (invalid.length) warning = guild.format('COMMAND_SELFROLE_INVALID', { roles: invalid.map((r) => r.name).join('**, **') });
|
||||
const _roles = roles?.value.filter((r) => selfrole.roles.includes(r.id) && !tooHigh.some((x) => x.id === r.id)) || [];
|
||||
// console.log(tooHigh, invalid, _roles);
|
||||
let warning = '';
|
||||
if (invalid.length) warning += guild.format('COMMAND_SELFROLE_INVALID', { roles: invalid.map((r) => r.name).join('**, **') });
|
||||
if (tooHigh.length) warning += `\n\n${guild.format('COMMAND_SELFROLE_TOOHIGH', { roles: tooHigh.map((r) => r.name).join('**, **') })}`;
|
||||
if(!_roles.length && subcommand !== 'clear') return { content: warning };
|
||||
|
||||
let index = null,
|
||||
|
@ -95,9 +95,9 @@ class SelfroleSetting extends Setting {
|
||||
components
|
||||
};
|
||||
|
||||
if (newChannel === oldChannel) {
|
||||
const msg = await oldChannel.messages.fetch(setting.message).catch(() => null);
|
||||
if (msg && newChannel === oldChannel) {
|
||||
await msg.edit(payload);
|
||||
if(msg) await msg.edit(payload);
|
||||
} else {
|
||||
const msg = await newChannel.send(payload);
|
||||
setting.message = msg.id;
|
||||
|
@ -209,7 +209,7 @@ class Setting extends Component {
|
||||
if (!response) return { error: true, message: invoker.format('ERR_TIMEOUT') };
|
||||
const content = response.content.toLowerCase();
|
||||
if(invoker.channel.permissionsFor(invoker.guild.me).has('MANAGE_MESSAGES'))
|
||||
await response.delete();
|
||||
await response.delete().catch(() => null);
|
||||
if (['cancel', 'abort', 'exit'].includes(content)) return {
|
||||
error: true,
|
||||
message: invoker.format('ERR_CANCEL')
|
||||
|
Loading…
Reference in New Issue
Block a user