Files
SupportBot/events/ready.js
T

62 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2020-12-18 13:37:56 +00:00
// SupportBot 6.0, Created by Emerald Services
2020-06-15 23:58:37 +01:00
// Ready Event
const Discord = require("discord.js");
const fs = require("fs");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
2020-12-18 13:37:56 +00:00
const tickets = yaml.load(fs.readFileSync('./storage/ticketreaction.yml', 'utf8'));
2021-02-02 16:07:28 +00:00
2020-06-15 23:58:37 +01:00
module.exports = async (bot) => {
bot.user.setActivity(supportbot.BotActivity, {
2021-02-02 17:01:58 +00:00
type: supportbot.ActivityType,
url: supportbot.StreamingURL
2021-02-02 16:07:28 +00:00
2020-06-15 23:58:37 +01:00
});
2021-02-02 16:07:28 +00:00
2020-06-15 23:58:37 +01:00
console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`)
console.log(`\u001b[37m`, `${supportbot.Bot_Name} has successfully connected to discord`)
console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`)
2020-12-18 13:37:56 +00:00
if (supportbot.ReactionTickets === "true") {
let chan1 = bot.channels.cache.find(channel => channel.name === supportbot.ReactionChannel)
if (!chan1) {
console.log('\u001b[33m', "[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!")
return false;
}
chan1.messages.fetch(tickets.ReactionMessage_ID).catch(r => {
let embed = new Discord.MessageEmbed()
.setTitle(supportbot.ReactionMessage.replace(/%reaction_emoji%/g, supportbot.ReactionEmoji))
2021-03-11 18:55:33 +00:00
.setColor(supportbot.SuccessColour)
2020-12-18 13:37:56 +00:00
.setFooter(supportbot.EmbedFooter);
2021-03-11 18:55:33 +00:00
if (supportbot.ReactionPanel_Description = true) {
embed.setDescription(supportbot.ReactionDescription)
}
if (supportbot.ReactionPanel_Thumbnail = true) {
embed.setThumbnail(supportbot.ReactionThumbnail)
}
2020-12-18 13:37:56 +00:00
bot.channels.cache.find(channel => channel.name === supportbot.ReactionChannel).send({
embed: embed
}).then(r => {
let data = {
"ReactionMessage_ID": `${r.id}`
}
let yamlStr = yaml.dump(data);
fs.writeFileSync('./storage/ticketreaction.yml', yamlStr, 'utf8');
2021-02-02 16:07:28 +00:00
r.react(supportbot.ReactionEmoji);
2020-12-18 13:37:56 +00:00
}).catch(e => {
console.log(e)
})
})
}
2021-02-02 13:50:53 +00:00
2021-02-05 21:39:16 +02:00
};