mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
Filter moderator role properly
This commit is contained in:
parent
bcec1ab48a
commit
09afcc80a6
@ -2,7 +2,7 @@ import Discord from 'discord.js';
|
||||
import TClient from '../client.js';
|
||||
import MessageTool from '../helpers/MessageTool.js';
|
||||
export default async(client:TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: 'ban'|'softban'|'kick'|'mute'|'warn'|'remind')=>{
|
||||
if (!MessageTool.isStaff(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
if (!MessageTool.isModerator(interaction.member)) return MessageTool.youNeedRole(interaction, 'dcmod');
|
||||
|
||||
const time = interaction.options.getString('time') ?? undefined;
|
||||
const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
|
||||
|
@ -14,4 +14,5 @@ export default class MessageTool {
|
||||
static formatMention =(mention:string, type:'user'|'channel'|'role')=>`<${type === 'role' ? '@&' : type === 'channel' ? '#' : '@'}${mention}>`;
|
||||
static isStaff =(guildMember:Discord.GuildMember)=>config.dcServer.staffRoles.map((x:string)=>config.dcServer.roles[x]).some((x:string)=>guildMember.roles.cache.has(x));
|
||||
static youNeedRole =(interaction:Discord.CommandInteraction, role:RoleKeys)=>interaction.reply(`You do not have ${this.formatMention(config.dcServer.roles[role], 'role')} role to use this command.`);
|
||||
static isModerator =(guildMember:Discord.GuildMember)=>config.dcServer.staffRoles.filter((x:string)=>/^admin|^dcmod/.test(x)).map((x:string)=>config.dcServer.roles[x]).some((x:string)=>guildMember.roles.cache.has(x));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user