SB-6.1-PRE

Ticket Reaction Create
This commit is contained in:
ItzEmerald committed 2021-02-02 16:07:28 +00:00
1 parent 358a25f522
commit 70405a1cd0
9 files changed
+27 -96

No files matched your search

+10 -28
View File
@@ -7,7 +7,6 @@ const fs = require("fs");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
const tickets = yaml.load(fs.readFileSync('./storage/ticketreaction.yml', 'utf8'));
const verif = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
module.exports = async (client, reaction, user) => {
@@ -20,34 +19,17 @@ module.exports = async (client, reaction, user) => {
if (supportbot.ReactionTickets === "true") {
if (reaction.message.id === tickets.ReactionMessage_ID) {
switch (reaction.emoji.id) {
case supportbot.ReactionEmoji: {
await reaction.users.remove(user.id)
if (reaction.emoji.name == supportbot.ReactionEmoji || reaction.emoji.id == supportbot.ReactionEmoji) {
await reaction.users.remove(user.id)
try {
const cmd = client.commands.get("ticket");
if(!cmd) return;
cmd.execute(message, "undefined");
} catch (error) {
console.error(error);
}
}
}
}
}
if (supportbot.Verification === "true") {
if (reaction.message.id === verif.verification_msg) {
switch (reaction.emoji.id) {
case supportbot.VerificationEmoji: {
await reaction.users.remove(user.id)
let r = reaction.message.channel.guild.roles.cache.find(r => r.name === "verified")
await reaction.message.channel.guild.members.cache.get(user.id).roles.add(r)
}
try {
const cmd = client.commands.get("ticket");
if(!cmd) return;
cmd.execute(message, "undefined");
} catch (error) {
console.error(error);
}
}
}
}
Executable → Regular
+5 -28
View File
@@ -7,13 +7,14 @@ const fs = require("fs");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
const tickets = yaml.load(fs.readFileSync('./storage/ticketreaction.yml', 'utf8'));
const verif = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
module.exports = async (bot) => {
bot.user.setActivity(supportbot.BotActivity, {
type: supportbot.ActvityType
});
console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`)
console.log(`\u001b[37m`, `${supportbot.Bot_Name} has successfully connected to discord`)
console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`)
@@ -40,37 +41,13 @@ module.exports = async (bot) => {
}
let yamlStr = yaml.dump(data);
fs.writeFileSync('./storage/ticketreaction.yml', yamlStr, 'utf8');
r.react(supportbot.ReactionEmoji)
r.react(supportbot.ReactionEmoji);
}).catch(e => {
console.log(e)
})
})
}
if (supportbot.Verification === "true") {
let chan2 = bot.channels.cache.find(channel => channel.name === supportbot.Verification_Channel)
if (!chan2) {
console.log('\u001b[33m', "[WARN] Verification Reaction panel is not setup, You can do so via the configuration file!")
return false;
}
chan2.messages.fetch(verif.verification_msg).catch(r => {
let embed = new Discord.MessageEmbed()
.setTitle(supportbot.VerificationMessage.replace(/%VerificationEmoji%/g, supportbot.VerificationEmoji))
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter);
bot.channels.cache.find(channel => channel.name === supportbot.Verification_Channel).send({embed: embed}).then(r => {
let data = {
"verification_msg": `${r.id}`
}
let yamlStr = yaml.dump(data);
fs.writeFileSync('./storage/verification.yml', yamlStr, 'utf8');
r.react(supportbot.VerificationEmoji)
}).catch(e => {
console.log(e)
})
})
}
};