robtic-discord-startup
Version:
easily set up a Discord bot with configurable settings
2 lines (1 loc) • 1.61 kB
JavaScript
import{MessageFlags as C}from"discord.js";import t from"chalk";var s=`${t.blueBright("[RobTic]")}`,a={info:e=>console.log(`${s} ${t.blue("[INFO]")} ${e}`),success:e=>console.log(`${s} ${t.green("[SUCCESS]")} ${e}`),warn:e=>console.warn(`${s} ${t.yellow("[WARN]")} ${e}`),error:e=>console.error(`${s} ${t.red("[ERROR]")} ${e}`),debug:e=>console.log(`${s} ${t.magenta("[DEBUG]")} ${e}`)};var i=class extends Error{constructor(o,n="COMMAND"){super(o);this.type=n;this.name=`[${n} ERROR]`}},g=(e,r="Unknown")=>{e instanceof i?a.error(`${e.name} (${r}): ${e.message}`):e instanceof Error?a.error(`[Unhandled Error] (${r}): ${e.stack}`):a.error(`[Unknown Error] (${r}): ${e}`)};import{EmbedBuilder as f}from"discord.js";var u={error:16731212,success:5025616,info:3447003,warning:16761095,default:5793266};var m=class{embed;constructor(r){let{title:o,description:n,fields:d=[],thumbnail:c,image:p,type:h="default"}=r;this.embed=new f().setTitle(o).setDescription(n).setColor(u[h]).setTimestamp(),d?.length&&this.embed.addFields(d.map(l=>({name:l.name,value:l.value,inline:l.inline??!1}))),c&&this.embed.setThumbnail(c),p&&this.embed.setImage(p)}get(){return this.embed}};var $=e=>new m({title:"Error",description:`\`\`\`${e}\`\`\``,type:"error"}).get();var b=class{data;admin;run;constructor(r){this.data=r.data,this.admin=r.admin,this.run=async(o,n)=>{try{await r.run(o,n)}catch{g(new i("\u26A0\uFE0F There was an error executing this command.","COMMAND"),`${process.cwd()}${r.data.name}`),await o.reply({embeds:[$("\u26A0\uFE0F There was an error executing this command.")],flags:C.Ephemeral})}}}};export{b as Command};