From f08b4b06693f189cfe61914bc2d17ff5871910b6 Mon Sep 17 00:00:00 2001 From: iFusion <31099360+iFusionFr@users.noreply.github.com> Date: Fri, 9 Oct 2020 14:49:06 +0200 Subject: [PATCH 1/4] Add command -rename for rename the ticket channel --- src/commands/rename.js | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/commands/rename.js diff --git a/src/commands/rename.js b/src/commands/rename.js new file mode 100644 index 0000000..e7de0a4 --- /dev/null +++ b/src/commands/rename.js @@ -0,0 +1,64 @@ +/** + * + * @name DiscordTickets + * @author eartharoid + * @license GNU-GPLv3 + * + */ + +const { MessageEmbed } = require('discord.js'); + +module.exports = { + name: 'rename', + description: 'Rename a ticket channel', + usage: '', + aliases: ['none'], + example: '', + args: true, + async execute(client, message, args, {config, Ticket}) { + const guild = client.guilds.cache.get(config.guild); + + let ticket = await Ticket.findOne({ + where: { + channel: message.channel.id + } + }); + + if (!ticket) { + return message.channel.send( + new MessageEmbed() + .setColor(config.err_colour) + .setAuthor(message.author.username, message.author.displayAvatarURL()) + .setTitle(':x: **This isn\'t a ticket channel**') + .setDescription('Use this command in the ticket channel you want to close, or mention the channel.') + .addField('Usage', `\`${config.prefix}${this.name} ${this.usage}\`\n`) + .addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`) + .setFooter(guild.name, guild.iconURL()) + ); + } + + if (!message.member.roles.cache.has(config.staff_role)) + return message.channel.send( + new MessageEmbed() + .setColor(config.err_colour) + .setAuthor(message.author.username, message.author.displayAvatarURL()) + .setTitle(':x: **No permission**') + .setDescription(`You don't have permission to rename this channel as you are not staff.`) + .addField('Usage', `\`${config.prefix}${this.name} ${this.usage}\`\n`) + .addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`) + .setFooter(guild.name, guild.iconURL()) + ); + + let newname = args.join(' '); + message.channel.setName(newname); + + message.channel.send( + new MessageEmbed() + .setColor(config.colour) + .setAuthor(message.author.username, message.author.displayAvatarURL()) + .setTitle(':white_check_mark: **Ticket updated**') + .setDescription('The name has been changed.') + .setFooter(client.user.username, client.user.displayAvatarURL()) + ); + } +}; \ No newline at end of file From 49f38005d6b5f7f445ee3bd67003691bd4606643 Mon Sep 17 00:00:00 2001 From: iFusion <31099360+iFusionFr@users.noreply.github.com> Date: Fri, 9 Oct 2020 14:51:21 +0200 Subject: [PATCH 2/4] Add files via upload --- src/commands/rename.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/rename.js b/src/commands/rename.js index e7de0a4..89f1111 100644 --- a/src/commands/rename.js +++ b/src/commands/rename.js @@ -1,7 +1,7 @@ /** * * @name DiscordTickets - * @author eartharoid + * @author iFusion for eartharoid * @license GNU-GPLv3 * */ From f0bef9c82d85c0632c68dde651b46bb5bfd613af Mon Sep 17 00:00:00 2001 From: iFusion <31099360+iFusionFr@users.noreply.github.com> Date: Fri, 9 Oct 2020 15:02:36 +0200 Subject: [PATCH 3/4] Update rename.js --- src/commands/rename.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/rename.js b/src/commands/rename.js index 89f1111..264ce56 100644 --- a/src/commands/rename.js +++ b/src/commands/rename.js @@ -30,7 +30,7 @@ module.exports = { .setColor(config.err_colour) .setAuthor(message.author.username, message.author.displayAvatarURL()) .setTitle(':x: **This isn\'t a ticket channel**') - .setDescription('Use this command in the ticket channel you want to close, or mention the channel.') + .setDescription('Use this command in the ticket channel you want to rename, or mention the channel.') .addField('Usage', `\`${config.prefix}${this.name} ${this.usage}\`\n`) .addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`) .setFooter(guild.name, guild.iconURL()) @@ -61,4 +61,4 @@ module.exports = { .setFooter(client.user.username, client.user.displayAvatarURL()) ); } -}; \ No newline at end of file +}; From a521ea0871425d8b0d65224e0c4cad14d48a4cf9 Mon Sep 17 00:00:00 2001 From: iFusion <31099360+iFusionFr@users.noreply.github.com> Date: Fri, 9 Oct 2020 15:03:08 +0200 Subject: [PATCH 4/4] Update rename.js --- src/commands/rename.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/rename.js b/src/commands/rename.js index 264ce56..2a6d05d 100644 --- a/src/commands/rename.js +++ b/src/commands/rename.js @@ -30,7 +30,7 @@ module.exports = { .setColor(config.err_colour) .setAuthor(message.author.username, message.author.displayAvatarURL()) .setTitle(':x: **This isn\'t a ticket channel**') - .setDescription('Use this command in the ticket channel you want to rename, or mention the channel.') + .setDescription('Use this command in the ticket channel you want to rename.') .addField('Usage', `\`${config.prefix}${this.name} ${this.usage}\`\n`) .addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`) .setFooter(guild.name, guild.iconURL())