Files
SupportBot-Dashboard/commands/rename.js
T

52 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-06-09 23:52:41 +01:00
// SupportBot
2020-01-26 22:35:45 +00:00
// Created by © 2020 Emerald Services
// Command: Rename
2019-06-09 23:52:41 +01:00
const Discord = require("discord.js");
2020-01-26 22:35:45 +00:00
const bot = new Discord.Client();
2019-06-09 23:52:41 +01:00
2020-01-26 22:35:45 +00:00
const fs = require("fs");
const yaml = require('js-yaml');
2019-06-09 23:52:41 +01:00
2020-01-26 22:35:45 +00:00
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
2019-06-09 23:52:41 +01:00
2020-01-26 22:35:45 +00:00
exports.run = async (bot, message, args) => {
console.log(`\u001b[33m`, `[${supportbot.Bot_Name}] > `, `\u001b[31;1m`, `${message.author.tag}`, `\u001b[32;1m`, `has executed`, `\u001b[31;1m`, `${supportbot.Prefix}${supportbot.Rename_Command}`);
let staffGroup = message.guild.roles.find(staffRole => staffRole.name === supportbot.StaffRole)
2019-06-09 23:52:41 +01:00
const rolemissing = new Discord.RichEmbed()
2020-01-26 22:35:45 +00:00
.setDescription(`:x: Looks like this server doesn't have the role **${supportbot.StaffRole}**`)
.setColor(supportbot.colour)
2019-06-09 23:52:41 +01:00
if (!staffGroup) return message.reply({embed: rolemissing});
const donothaverole = new Discord.RichEmbed()
2020-01-26 22:35:45 +00:00
.setDescription(`:x: Sorry! You cannot use this command with the role **${supportbot.StaffRole}**`)
.setColor(supportbot.colour)
2019-06-09 23:52:41 +01:00
if (!message.member.roles.has(staffGroup.id)) return message.reply({embed: donothaverole});
const outsideticket = new Discord.RichEmbed()
.setDescription(`:x: Cannot use this command becase you are outside a ticket channel.`)
2020-01-26 22:35:45 +00:00
.setColor(supportbot.colour)
if (!message.channel.name.startsWith(`${supportbot.Ticket_Channel_Name}-`)) return message.channel.send({embed: outsideticket});
2019-06-09 23:52:41 +01:00
const renameto = args.join(" ")
2020-01-26 22:35:45 +00:00
message.channel.setName(`${supportbot.Ticket_Channel_Name}-${renameto}`)
2019-06-09 23:52:41 +01:00
// Renamed Ticket Logistic
const logEmbed = new Discord.RichEmbed()
.setTitle(":ticket: Ticket Renamed")
2020-01-26 22:35:45 +00:00
.setDescription(`<@${message.author.id}> has renamed a ticket to ${supportbot.Ticket_Channel_Name}-${renameto}`)
.setColor(supportbot.EmbedColour)
.setFooter(supportbot.EmbedFooter)
2019-06-09 23:52:41 +01:00
2020-01-26 22:35:45 +00:00
let logChannel = message.guild.channels.find(TicketChannel => TicketChannel.name === `${supportbot.Ticket_Logs}`);
if(!logChannel) return message.channel.send(`:x: Error! Could not find the logs channel **${supportbot.Ticket_Logs}**`);
2019-06-09 23:52:41 +01:00
2020-01-26 22:35:45 +00:00
logChannel.send({embed: logEmbed});
2019-07-24 16:52:30 -06:00
2020-01-26 22:35:45 +00:00
};
2019-06-09 23:52:41 +01:00
exports.help = {
2020-01-26 22:35:45 +00:00
name: supportbot.Rename_Command,
2019-11-29 22:34:57 +00:00
}