Files
SupportBot/events/ready.js
T

92 lines
4.1 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");
2021-09-11 15:29:21 +01:00
const { MessageActionRow, MessageButton } = require('discord.js');
2020-06-15 23:58:37 +01:00
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
2021-09-11 15:29:21 +01:00
module.exports = async bot => {
2020-06-15 23:58:37 +01:00
bot.user.setActivity(supportbot.BotActivity, {
2021-02-02 17:01:58 +00:00
type: supportbot.ActivityType,
2021-09-11 15:29:21 +01:00
url: supportbot.StreamingURL
2020-06-15 23:58:37 +01:00
});
2021-02-02 16:07:28 +00:00
2021-06-15 18:09:24 +01:00
console.log(`\u001b[32m`, `┏━━━┓╋╋╋╋╋╋╋╋╋╋╋╋╋┏┓┏━━┓╋╋╋┏┓`)
console.log(`\u001b[32m`, `┃┏━┓┃╋╋╋╋╋╋╋╋╋╋╋╋┏┛┗┫┏┓┃╋╋┏┛┗┓`)
console.log(`\u001b[32m`, `┃┗━━┳┓┏┳━━┳━━┳━━┳┻┓┏┫┗┛┗┳━┻┓┏┛`)
console.log(`\u001b[32m`, `┗━━┓┃┃┃┃┏┓┃┏┓┃┏┓┃┏┫┃┃┏━┓┃┏┓┃┃`)
console.log(`\u001b[32m`, `┃┗━┛┃┗┛┃┗┛┃┗┛┃┗┛┃┃┃┗┫┗━┛┃┗┛┃┗┓`)
console.log(`\u001b[32m`, `┗━━━┻━━┫┏━┫┏━┻━━┻┛┗━┻━━━┻━━┻━┛`)
console.log(`\u001b[32m`, `┗╋╋╋╋╋╋╋┃┃╋┃┃`)
console.log(`\u001b[32m`, `╋╋╋╋╋╋╋┗┛╋┗┛`)
2021-09-11 15:29:21 +01:00
console.log(` `)
2021-06-15 18:09:24 +01:00
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`)
2021-09-11 15:29:21 +01:00
console.log(` `)
2021-08-05 01:03:58 +01:00
console.log(`\u001b[33m`, `${supportbot.Bot_Name} v${supportbot.SupportBot_Version}`, `\u001b[36m`, `Connected to Discord`)
2021-09-11 15:29:21 +01:00
console.log(`\u001b[33m`, `Documentation:`, `\u001b[36m`, `https://supportbot.emeraldsrv.dev`)
2021-06-15 18:09:24 +01:00
console.log(`\u001b[33m`, `Discord:`, `\u001b[36m`, `https://emeraldsrv.dev/discord`)
console.log(`\u001b[33m`, `Hosting:`, `\u001b[36m`, `https://emeraldsrv.dev/hosting`)
2021-09-11 15:29:21 +01:00
console.log(` `)
2021-06-15 18:09:24 +01:00
console.log(`\u001b[37m`, `SupportBot proudly created by Emerald Services`)
2021-09-11 15:29:21 +01:00
console.log(` `)
2021-06-15 18:09:24 +01:00
console.log(`\u001b[31m`, `――――――――――――――――――――――――――――――――――――――――――――`)
2020-12-18 13:37:56 +00:00
2021-06-15 18:09:24 +01:00
2021-09-11 15:29:21 +01:00
if (supportbot.ReactionTickets) {
2021-06-15 18:09:24 +01:00
let chan1 = bot.channels.cache.find(channel => channel.name === supportbot.ReactionChannel)
2020-12-18 13:37:56 +00:00
if (!chan1) {
console.log('\u001b[33m', "[WARN] Ticket reaction panel is not setup, You can do so via the configuration file!")
return false;
}
2021-09-11 15:29:21 +01:00
chan1.messages.fetch(tickets.ReactionMessage_ID).catch(async r => {
2020-12-18 13:37:56 +00:00
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-09-11 15:29:21 +01:00
if (supportbot.ReactionPanel_Description) {
2021-03-24 16:25:16 +00:00
embed.setDescription(supportbot.ReactionDescription)
}
2021-09-11 15:29:21 +01:00
if (supportbot.ReactionPanel_Thumbnail) {
2021-03-24 16:25:16 +00:00
embed.setThumbnail(supportbot.ReactionThumbnail)
}
2020-12-18 13:37:56 +00:00
2021-09-11 15:29:21 +01:00
if (supportbot.ReactionPanel_Image) {
2021-03-24 20:56:57 +00:00
embed.setImage(supportbot.ReactionImage)
2021-03-24 16:25:16 +00:00
}
2021-09-11 15:29:21 +01:00
let button = new MessageButton()
.setLabel('Open Ticket')
.setCustomId('openticket')
.setStyle('PRIMARY')
let row = new MessageActionRow()
.addComponents(button)
2021-03-24 16:25:16 +00:00
2021-09-11 15:29:21 +01:00
await chan1.send({
embeds: [embed],
components: [row]
2020-12-18 13:37:56 +00:00
}).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
2020-12-18 13:37:56 +00:00
}).catch(e => {
2021-09-11 15:29:21 +01:00
console.log("Raw"+e)
2020-12-18 13:37:56 +00:00
})
})
}
2021-03-24 16:25:16 +00:00
};