mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
"remove" command
This commit is contained in:
parent
d2034c5a14
commit
82473db65c
@ -93,6 +93,8 @@ module.exports = class AddCommand extends Command {
|
||||
ATTACH_FILES: true
|
||||
}, `${message.author.tag} added ${member.user.tag} to the ticket`);
|
||||
|
||||
await this.client.tickets.archives.updateMember(ticket.id, member);
|
||||
|
||||
this.client.log.info(`${message.author.tag} added ${member.user.tag} to ${ticket.id}`);
|
||||
}
|
||||
};
|
@ -30,5 +30,66 @@ module.exports = class RemoveCommand extends Command {
|
||||
async execute(message, args) {
|
||||
let settings = await message.guild.settings;
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
let ticket = message.mentions.channels.first() ?? message.channel;
|
||||
let t_row = await this.client.tickets.resolve(ticket.id, message.guild.id);
|
||||
|
||||
if (!t_row) {
|
||||
return await message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.error_colour)
|
||||
.setTitle(i18n('commands.remove.response.not_a_ticket.title'))
|
||||
.setDescription(i18n('commands.remove.response.not_a_ticket.description'))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
}
|
||||
|
||||
let member = message.mentions.members.first() ?? message.guild.members.cache.get(args);
|
||||
|
||||
if (!member) {
|
||||
return await message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.error_colour)
|
||||
.setTitle(i18n('commands.remove.response.no_member.title'))
|
||||
.setDescription(i18n('commands.remove.response.no_member.description'))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
}
|
||||
|
||||
if (t_row.creator !== message.author.id && !await message.member.isStaff()) {
|
||||
return await message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.error_colour)
|
||||
.setTitle(i18n('commands.remove.response.no_permission.title'))
|
||||
.setDescription(i18n('commands.remove.response.no_permission.description'))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
}
|
||||
|
||||
if (message.channel.id !== ticket.id) {
|
||||
await message.channel.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.success_colour)
|
||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||
.setTitle(i18n('commands.remove.response.removed.title'))
|
||||
.setDescription(i18n('commands.remove.response.removed.description', member.toString(), ticket.toString()))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
}
|
||||
|
||||
await ticket.send(
|
||||
new MessageEmbed()
|
||||
.setColor(settings.colour)
|
||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||
.setTitle(i18n('ticket.member_removed.title'))
|
||||
.setDescription(i18n('ticket.member_removed.description', member.toString(), message.author.toString()))
|
||||
.setFooter(settings.footer, message.guild.iconURL())
|
||||
);
|
||||
|
||||
await ticket.permissionOverwrites
|
||||
.get(member.user.id)
|
||||
?.delete(`${message.author.tag} removed ${member.user.tag} from the ticket`);
|
||||
|
||||
this.client.log.info(`${message.author.tag} removed ${member.user.tag} from ${ticket.id}`);
|
||||
}
|
||||
};
|
@ -55,7 +55,7 @@ module.exports = class MessageReactionRemoveEventListener extends EventListener
|
||||
|
||||
await channel.permissionOverwrites
|
||||
.get(member.user.id)
|
||||
.delete(`Ticket released by ${member.user.tag}`);
|
||||
?.delete(`Ticket released by ${member.user.tag}`);
|
||||
|
||||
let cat_row = await this.client.db.models.Category.findOne({
|
||||
where: {
|
||||
|
@ -303,7 +303,24 @@
|
||||
},
|
||||
"description": "Remove a member from a ticket",
|
||||
"name": "remove",
|
||||
"response": {}
|
||||
"response": {
|
||||
"removed": {
|
||||
"description": "%s has been removed from %s.",
|
||||
"title": "✅ Member removed"
|
||||
},
|
||||
"no_member": {
|
||||
"description": "Please mention the member you want to remove.",
|
||||
"title": "❌ Unknown member"
|
||||
},
|
||||
"no_permission": {
|
||||
"description": "You are not the creator of this ticket and you are not a staff member; you can't remove members from this ticket.",
|
||||
"title": "❌ Insufficient permission"
|
||||
},
|
||||
"not_a_ticket": {
|
||||
"description": "Please use this command in the ticket channel, or mention the channel.",
|
||||
"title": "❌ This isn't a ticket channel"
|
||||
}
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"aliases": {
|
||||
@ -374,6 +391,10 @@
|
||||
"description": "%s has been added by %s",
|
||||
"title": "Member added"
|
||||
},
|
||||
"member_removed": {
|
||||
"description": "%s has been removed by %s",
|
||||
"title": "Member removed"
|
||||
},
|
||||
"released": {
|
||||
"description": "%s has released this ticket.",
|
||||
"title": "✅ Ticket released"
|
||||
|
Loading…
Reference in New Issue
Block a user