Files
SupportBot/events/ready.js
T

66 lines
2.5 KiB
JavaScript
Raw 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
2021-03-24 16:25:16 +00:00
if (supportbot.ReactionTickets === true) {
2020-12-18 13:37:56 +00:00
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))
.setColor(supportbot.SuccessColour)
.setFooter(supportbot.EmbedFooter);
2021-03-24 16:25:16 +00:00
2021-03-30 20:18:37 +01:00
if (supportbot.ReactionPanel_Description === true) {
2021-03-24 16:25:16 +00:00
embed.setDescription(supportbot.ReactionDescription)
}
2021-03-30 20:18:37 +01:00
if (supportbot.ReactionPanel_Thumbnail === true) {
2021-03-24 16:25:16 +00:00
embed.setThumbnail(supportbot.ReactionThumbnail)
}
2020-12-18 13:37:56 +00:00
2021-03-30 20:18:37 +01:00
if (supportbot.ReactionPanel_Image === true) {
2021-03-24 20:56:57 +00:00
embed.setImage(supportbot.ReactionImage)
2021-03-24 16:25:16 +00:00
}
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-03-24 16:25:16 +00:00
};