1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 16:30:58 -05:00
Daggerbot-TS/src/helpers/MessageTool.ts

27 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-08-29 20:21:53 -04:00
import Discord from 'discord.js';
2023-10-08 18:03:17 -04:00
import ConfigHelper from './ConfigHelper.js';
const config = ConfigHelper.readConfig();
2023-10-06 01:54:27 -04:00
type RoleKeys = keyof typeof config.mainServer.roles;
2023-08-29 20:21:53 -04:00
export default class MessageTool {
static embedStruct(color:Discord.ColorResolvable, title:string, description?:string|null, image?:string|null){
const embed = new Discord.EmbedBuilder().setColor(color).setTitle(title);
if (description) embed.setDescription(description);
if (image) embed.setImage(image);
return embed
}
static concatMessage(...messages:string[]){
return messages.join('\n')
}
static formatMention(mention:string, type:'user'|'channel'|'role'){
return `<@${type === 'role' ? '&' : type === 'channel' ? '#' : ''}${mention}>`
}
2023-10-06 01:54:27 -04:00
static isStaff(guildMember:Discord.GuildMember){
return config.mainServer.staffRoles.map((x:string)=>config.mainServer.roles[x]).some((x:string)=>guildMember.roles.cache.has(x));
}
static youNeedRole(interaction:Discord.CommandInteraction, role:RoleKeys){
return interaction.reply(`This command is restricted to ${this.formatMention(config.mainServer.roles[role], 'role')}`);
}
2023-08-29 20:21:53 -04:00
}
// I want to come up with better name instead of calling this file "MessageTool", but I am super bad at naming things.