mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Merge pull request #209 from discord-tickets/d.js-v13
Update to discord.js v13
This commit is contained in:
commit
6d4248d563
36
package.json
36
package.json
@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "@eartharoid/discord-tickets",
|
"name": "@eartharoid/discord-tickets",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0-dev",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "An open-source Discord bot for ticket management",
|
"description": "An open-source Discord bot for ticket management",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"contributors:add": "all-contributors add",
|
"contributors:add": "all-contributors add",
|
||||||
"contributors:generate": "all-contributors generate",
|
"contributors:generate": "all-contributors generate",
|
||||||
"lint": "eslint src --fix",
|
"lint": "eslint src --fix",
|
||||||
"start": "node src/",
|
"start": "node src/",
|
||||||
"test": "echo \"Nothing to test! Run with 'npm start'\" && exit 1"
|
"test": "echo \"Nothing to test! Run with 'npm start'\" && exit 1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14"
|
"node": ">=16.6"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -32,33 +32,33 @@
|
|||||||
"funding": "https://github.com/discord-tickets/bot/?sponsor=1",
|
"funding": "https://github.com/discord-tickets/bot/?sponsor=1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eartharoid/i18n": "^1.0.0",
|
"@eartharoid/i18n": "^1.0.0",
|
||||||
"boxen": "^5.0.0",
|
"boxen": "^5.0.1",
|
||||||
"command-line-args": "^5.1.1",
|
"command-line-args": "^5.2.0",
|
||||||
"cryptr": "^6.0.2",
|
"cryptr": "^6.0.2",
|
||||||
"discord.js": "^12.5.1",
|
"discord.js": "^13.1.0",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.6.0",
|
||||||
"jsonschema": "^1.4.0",
|
"jsonschema": "^1.4.0",
|
||||||
"keyv": "^4.0.3",
|
"keyv": "^4.0.3",
|
||||||
"leeks.js": "^0.2.2",
|
"leeks.js": "^0.2.2",
|
||||||
"leekslazylogger-fastify": "^0.1.1",
|
"leekslazylogger": "^3.0.2",
|
||||||
"mustache": "^4.2.0",
|
"mustache": "^4.2.0",
|
||||||
"node-emoji": "^1.10.0",
|
"node-emoji": "^1.11.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"semver": "^7.3.4",
|
"semver": "^7.3.5",
|
||||||
"sequelize": "^6.5.0",
|
"sequelize": "^6.6.5",
|
||||||
"string-argv": "^0.3.1",
|
"string-argv": "^0.3.1",
|
||||||
"terminal-link": "^2.1.1",
|
"terminal-link": "^2.1.1",
|
||||||
"to-time-monthsfork": "^1.1.4"
|
"to-time-monthsfork": "^1.1.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"all-contributors-cli": "^6.20.0",
|
"all-contributors-cli": "^6.20.0",
|
||||||
"eslint": "^7.21.0",
|
"eslint": "^7.32.0",
|
||||||
"mariadb": "^2.5.2",
|
"mariadb": "^2.5.4",
|
||||||
"mysql2": "^2.2.5",
|
"mysql2": "^2.3.0",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.12",
|
||||||
"pg": "^8.5.1",
|
"pg": "^8.7.1",
|
||||||
"pg-hstore": "^2.3.3",
|
"pg-hstore": "^2.3.4",
|
||||||
"tedious": "^11.0.3"
|
"tedious": "^11.4.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"sqlite3": "^5.0.2"
|
"sqlite3": "^5.0.2"
|
||||||
|
1373
pnpm-lock.yaml
1373
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@
|
|||||||
"description": "https:\/\/discordtickets.app",
|
"description": "https:\/\/discordtickets.app",
|
||||||
"features": null,
|
"features": null,
|
||||||
"images": [
|
"images": [
|
||||||
"quay.io\/parkervcp\/pterodactyl-images:debian_nodejs-14"
|
"quay.io\/parkervcp\/pterodactyl-images:debian_nodejs-16"
|
||||||
],
|
],
|
||||||
"file_denylist": [],
|
"file_denylist": [],
|
||||||
"startup": "if [[ ! -z ${VERSION} ]]; then\r\n echo -e \\\"Using version ${VERSION}\\\";\r\nelse\r\n echo -e \\\"Please set the VERSION variable \\(e.g. v3.0.0\\)\\\";\r\n exit 0;\r\nfi;\r\n\r\nif [[ -d .git ]]; then\r\n git fetch --all --tags;\r\n git checkout tags\/${VERSION};\r\nfi;\r\n\r\nif [[ ! -z ${PLUGINS} ]]; then\r\n \/usr\/local\/bin\/npm install ${PLUGINS};\r\nfi;\r\n\r\nif [ -f \/home\/container\/package.json ]; then\r\n \/usr\/local\/bin\/npm install --production;\r\nfi;\r\n\r\n\/usr\/local\/bin\/npm start",
|
"startup": "if [[ ! -z ${VERSION} ]]; then\r\n echo -e \\\"Using version ${VERSION}\\\";\r\nelse\r\n echo -e \\\"Please set the VERSION variable \\(e.g. v3.0.0\\)\\\";\r\n exit 0;\r\nfi;\r\n\r\nif [[ -d .git ]]; then\r\n git fetch --all --tags;\r\n git checkout tags\/${VERSION};\r\nfi;\r\n\r\nif [[ ! -z ${PLUGINS} ]]; then\r\n \/usr\/local\/bin\/npm install ${PLUGINS};\r\nfi;\r\n\r\nif [ -f \/home\/container\/package.json ]; then\r\n \/usr\/local\/bin\/npm install --production;\r\nfi;\r\n\r\n\/usr\/local\/bin\/npm start",
|
||||||
|
@ -36,65 +36,75 @@ module.exports = class AddCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const ticket = message.mentions.channels.first() ?? message.channel;
|
const ticket = message.mentions.channels.first() ?? message.channel;
|
||||||
const t_row = await this.client.tickets.resolve(ticket.id, message.guild.id);
|
const t_row = await this.client.tickets.resolve(ticket.id, message.guild.id);
|
||||||
|
|
||||||
if (!t_row) {
|
if (!t_row) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.add.response.not_a_ticket.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.add.response.not_a_ticket.description'))
|
.setTitle(i18n('commands.add.response.not_a_ticket.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.add.response.not_a_ticket.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const member = message.mentions.members.first() ?? message.guild.members.cache.get(args);
|
const member = message.mentions.members.first() ?? message.guild.members.cache.get(args);
|
||||||
|
|
||||||
if (!member) {
|
if (!member) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.add.response.no_member.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.add.response.no_member.description'))
|
.setTitle(i18n('commands.add.response.no_member.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.add.response.no_member.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t_row.creator !== message.author.id && !await message.member.isStaff()) {
|
if (t_row.creator !== message.author.id && !await this.client.utils.isStaff(message.member)) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.add.response.no_permission.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.add.response.no_permission.description'))
|
.setTitle(i18n('commands.add.response.no_permission.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.add.response.no_permission.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.channel.id !== ticket.id) {
|
if (message.channel.id !== ticket.id) {
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.success_colour)
|
||||||
.setTitle(i18n('commands.add.response.added.title'))
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.add.response.added.description', member.toString(), ticket.toString()))
|
.setTitle(i18n('commands.add.response.added.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.add.response.added.description', member.toString(), ticket.toString()))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await ticket.send(
|
await ticket.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.colour)
|
||||||
.setTitle(i18n('ticket.member_added.title'))
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.setDescription(i18n('ticket.member_added.description', member.toString(), message.author.toString()))
|
.setTitle(i18n('ticket.member_added.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('ticket.member_added.description', member.toString(), message.author.toString()))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
await ticket.updateOverwrite(member, {
|
await ticket.permissionOverwrites.edit(member, {
|
||||||
ATTACH_FILES: true,
|
ATTACH_FILES: true,
|
||||||
READ_MESSAGE_HISTORY: true,
|
READ_MESSAGE_HISTORY: true,
|
||||||
SEND_MESSAGES: true,
|
SEND_MESSAGES: true,
|
||||||
@ -105,4 +115,4 @@ module.exports = class AddCommand extends Command {
|
|||||||
|
|
||||||
this.client.log.info(`${message.author.tag} added ${member.user.tag} to ${ticket.id}`);
|
this.client.log.info(`${message.author.tag} added ${member.user.tag} to ${ticket.id}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,19 +33,21 @@ module.exports = class BlacklistCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const member = message.mentions.members.first();
|
const member = message.mentions.members.first();
|
||||||
|
|
||||||
if (member && (await member.isStaff() || member.hasPermission(this.permissions))) {
|
if (member && (await this.client.utils.isStaff(member) || member.permissions.has(this.permissions))) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.blacklist.response.illegal_action.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.blacklist.response.illegal_action.description', `<@${member.id}>`))
|
.setTitle(i18n('commands.blacklist.response.illegal_action.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.blacklist.response.illegal_action.description', `<@${member.id}>`))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,13 +62,15 @@ module.exports = class BlacklistCommand extends Command {
|
|||||||
} else if (/\d{17,19}/.test(input)) {
|
} else if (/\d{17,19}/.test(input)) {
|
||||||
id = input;
|
id = input;
|
||||||
} else if (settings.blacklist.length === 0) {
|
} else if (settings.blacklist.length === 0) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.blacklist.response.empty_list.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.blacklist.response.empty_list.description', settings.command_prefix))
|
.setTitle(i18n('commands.blacklist.response.empty_list.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.blacklist.response.empty_list.description', settings.command_prefix))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// list blacklisted members
|
// list blacklisted members
|
||||||
const blacklist = settings.blacklist.map(element => {
|
const blacklist = settings.blacklist.map(element => {
|
||||||
@ -74,13 +78,15 @@ module.exports = class BlacklistCommand extends Command {
|
|||||||
if (is_role) return `» <@&${element}> (\`${element}\`)`;
|
if (is_role) return `» <@&${element}> (\`${element}\`)`;
|
||||||
else return `» <@${element}> (\`${element}\`)`;
|
else return `» <@${element}> (\`${element}\`)`;
|
||||||
});
|
});
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.blacklist.response.list.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(blacklist.join('\n'))
|
.setTitle(i18n('commands.blacklist.response.list.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(blacklist.join('\n'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const is_role = role !== undefined || message.guild.roles.cache.has(id);
|
const is_role = role !== undefined || message.guild.roles.cache.has(id);
|
||||||
@ -91,25 +97,29 @@ module.exports = class BlacklistCommand extends Command {
|
|||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
new_blacklist.push(id);
|
new_blacklist.push(id);
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n(`commands.blacklist.response.${member_or_role}_added.title`))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n(`commands.blacklist.response.${member_or_role}_added.description`, id))
|
.setTitle(i18n(`commands.blacklist.response.${member_or_role}_added.title`))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n(`commands.blacklist.response.${member_or_role}_added.description`, id))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
new_blacklist.splice(index, 1);
|
new_blacklist.splice(index, 1);
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n(`commands.blacklist.response.${member_or_role}_removed.title`))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n(`commands.blacklist.response.${member_or_role}_removed.description`, id))
|
.setTitle(i18n(`commands.blacklist.response.${member_or_role}_removed.title`))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n(`commands.blacklist.response.${member_or_role}_removed.description`, id))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.blacklist = new_blacklist;
|
settings.blacklist = new_blacklist;
|
||||||
await settings.save();
|
await settings.save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,6 @@ const {
|
|||||||
} = require('discord.js');
|
} = require('discord.js');
|
||||||
const { Op } = require('sequelize');
|
const { Op } = require('sequelize');
|
||||||
const toTime = require('to-time-monthsfork');
|
const toTime = require('to-time-monthsfork');
|
||||||
const { footer } = require('../utils/discord');
|
|
||||||
|
|
||||||
module.exports = class CloseCommand extends Command {
|
module.exports = class CloseCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@ -60,7 +59,7 @@ module.exports = class CloseCommand extends Command {
|
|||||||
const arg_reason = this.args[1].name;
|
const arg_reason = this.args[1].name;
|
||||||
const arg_time = this.args[2].name;
|
const arg_time = this.args[2].name;
|
||||||
|
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
if (args[arg_time]) {
|
if (args[arg_time]) {
|
||||||
@ -69,13 +68,15 @@ module.exports = class CloseCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
period = toTime(args[arg_time]).ms();
|
period = toTime(args[arg_time]).ms();
|
||||||
} catch {
|
} catch {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.invalid_time.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.close.response.invalid_time.description'))
|
.setTitle(i18n('commands.close.response.invalid_time.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.invalid_time.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const tickets = await this.client.db.models.Ticket.findAndCountAll({
|
const tickets = await this.client.db.models.Ticket.findAndCountAll({
|
||||||
@ -86,38 +87,46 @@ module.exports = class CloseCommand extends Command {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (tickets.count === 0) {
|
if (tickets.count === 0) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.no_tickets.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.close.response.no_tickets.description'))
|
.setTitle(i18n('commands.close.response.no_tickets.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.no_tickets.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const collector_message = await message.channel.send(
|
const collector_message = await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.confirm_multiple.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.close.response.confirm_multiple.description', tickets.count, tickets.count))
|
.setTitle(i18n('commands.close.response.confirm_multiple.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.confirm_multiple.description', tickets.count, tickets.count))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
await collector_message.react('✅');
|
await collector_message.react('✅');
|
||||||
|
|
||||||
const collector_filter = (reaction, user) => user.id === message.author.id && reaction.emoji.name === '✅';
|
const filter = (reaction, user) => user.id === message.author.id && reaction.emoji.name === '✅';
|
||||||
|
const collector = collector_message.createReactionCollector({
|
||||||
const collector = collector_message.createReactionCollector(collector_filter, { time: 30000 });
|
filter,
|
||||||
|
time: 30000
|
||||||
|
});
|
||||||
|
|
||||||
collector.on('collect', async () => {
|
collector.on('collect', async () => {
|
||||||
await collector_message.reactions.removeAll();
|
await collector_message.reactions.removeAll();
|
||||||
|
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.closed_multiple.title', tickets.count, tickets.count))
|
.setColor(settings.success_colour)
|
||||||
.setDescription(i18n('commands.close.response.closed_multiple.description', tickets.count, tickets.count))
|
.setTitle(i18n('commands.close.response.closed_multiple.title', tickets.count, tickets.count))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.closed_multiple.description', tickets.count, tickets.count))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
for (const ticket of tickets.rows) {
|
for (const ticket of tickets.rows) {
|
||||||
await this.client.tickets.close(ticket.id, message.author.id, message.guild.id, args[arg_reason]);
|
await this.client.tickets.close(ticket.id, message.author.id, message.guild.id, args[arg_reason]);
|
||||||
@ -128,14 +137,16 @@ module.exports = class CloseCommand extends Command {
|
|||||||
collector.on('end', async collected => {
|
collector.on('end', async collected => {
|
||||||
if (collected.size === 0) {
|
if (collected.size === 0) {
|
||||||
await collector_message.reactions.removeAll();
|
await collector_message.reactions.removeAll();
|
||||||
await collector_message.edit(
|
await collector_message.edit({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setColor(settings.error_colour)
|
||||||
.setTitle(i18n('commands.close.response.confirmation_timeout.title'))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.close.response.confirmation_timeout.description'))
|
.setTitle(i18n('commands.close.response.confirmation_timeout.title'))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.confirmation_timeout.description'))
|
||||||
);
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await collector_message
|
await collector_message
|
||||||
.delete()
|
.delete()
|
||||||
@ -155,41 +166,49 @@ module.exports = class CloseCommand extends Command {
|
|||||||
t_row = await this.client.tickets.resolve(args[arg_ticket], message.guild.id);
|
t_row = await this.client.tickets.resolve(args[arg_ticket], message.guild.id);
|
||||||
|
|
||||||
if (!t_row) {
|
if (!t_row) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.unresolvable.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.close.response.unresolvable.description', args[arg_ticket]))
|
.setTitle(i18n('commands.close.response.unresolvable.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.unresolvable.description', args[arg_ticket]))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
||||||
|
|
||||||
if (!t_row) {
|
if (!t_row) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.not_a_ticket.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.close.response.not_a_ticket.description', settings.command_prefix))
|
.setTitle(i18n('commands.close.response.not_a_ticket.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.not_a_ticket.description', settings.command_prefix))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const collector_message = await message.channel.send(
|
const collector_message = await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.confirm.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.close.response.confirm.description', t_row.number))
|
.setTitle(i18n('commands.close.response.confirm.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.confirm.description', t_row.number))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
await collector_message.react('✅');
|
await collector_message.react('✅');
|
||||||
|
|
||||||
const collector_filter = (reaction, user) => user.id === message.author.id && reaction.emoji.name === '✅';
|
const filter = (reaction, user) => user.id === message.author.id && reaction.emoji.name === '✅';
|
||||||
|
const collector = collector_message.createReactionCollector({
|
||||||
const collector = collector_message.createReactionCollector(collector_filter, { time: 30000 });
|
filter,
|
||||||
|
time: 30000
|
||||||
|
});
|
||||||
|
|
||||||
collector.on('collect', async () => {
|
collector.on('collect', async () => {
|
||||||
collector.stop();
|
collector.stop();
|
||||||
@ -198,13 +217,15 @@ module.exports = class CloseCommand extends Command {
|
|||||||
await collector_message.delete();
|
await collector_message.delete();
|
||||||
} else {
|
} else {
|
||||||
await collector_message.reactions.removeAll();
|
await collector_message.reactions.removeAll();
|
||||||
await collector_message.edit(
|
await collector_message.edit({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.close.response.closed.title'))
|
.setColor(settings.success_colour)
|
||||||
.setDescription(i18n('commands.close.response.closed.description', t_row.number))
|
.setTitle(i18n('commands.close.response.closed.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.closed.description', t_row.number))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.client.tickets.close(t_row.id, message.author.id, message.guild.id, args[arg_reason]);
|
await this.client.tickets.close(t_row.id, message.author.id, message.guild.id, args[arg_reason]);
|
||||||
@ -213,14 +234,16 @@ module.exports = class CloseCommand extends Command {
|
|||||||
collector.on('end', async collected => {
|
collector.on('end', async collected => {
|
||||||
if (collected.size === 0) {
|
if (collected.size === 0) {
|
||||||
await collector_message.reactions.removeAll();
|
await collector_message.reactions.removeAll();
|
||||||
await collector_message.edit(
|
await collector_message.edit({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setColor(settings.error_colour)
|
||||||
.setTitle(i18n('commands.close.response.confirmation_timeout.title'))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.close.response.confirmation_timeout.description'))
|
.setTitle(i18n('commands.close.response.confirmation_timeout.title'))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setDescription(i18n('commands.close.response.confirmation_timeout.description'))
|
||||||
);
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await collector_message
|
await collector_message
|
||||||
.delete()
|
.delete()
|
||||||
@ -234,4 +257,4 @@ module.exports = class CloseCommand extends Command {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ module.exports = class HelpCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const cmd = this.manager.commands.find(command => command.aliases.includes(args.toLowerCase()));
|
const cmd = this.manager.commands.find(command => command.aliases.includes(args.toLowerCase()));
|
||||||
@ -41,9 +41,9 @@ module.exports = class HelpCommand extends Command {
|
|||||||
if (cmd) {
|
if (cmd) {
|
||||||
return await cmd.sendUsage(message.channel, args);
|
return await cmd.sendUsage(message.channel, args);
|
||||||
} else {
|
} else {
|
||||||
const is_staff = await message.member.isStaff();
|
const is_staff = await this.client.utils.isStaff(message.member);
|
||||||
const commands = this.manager.commands.filter(command => {
|
const commands = this.manager.commands.filter(command => {
|
||||||
if (command.permissions.length >= 1) return message.member.hasPermission(command.permissions);
|
if (command.permissions.length >= 1) return message.member.permissions.has(command.permissions);
|
||||||
else if (command.staff_only) return is_staff;
|
else if (command.staff_only) return is_staff;
|
||||||
else return true;
|
else return true;
|
||||||
});
|
});
|
||||||
@ -53,14 +53,16 @@ module.exports = class HelpCommand extends Command {
|
|||||||
: command.description;
|
: command.description;
|
||||||
return `**\`${settings.command_prefix}${command.name}\` ·** ${description}`;
|
return `**\`${settings.command_prefix}${command.name}\` ·** ${description}`;
|
||||||
});
|
});
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.help.response.list.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.help.response.list.description', { prefix: settings.command_prefix }))
|
.setTitle(i18n('commands.help.response.list.title'))
|
||||||
.addField(i18n('commands.help.response.list.fields.commands'), list.join('\n'))
|
.setDescription(i18n('commands.help.response.list.description', { prefix: settings.command_prefix }))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.addField(i18n('commands.help.response.list.fields.commands'), list.join('\n'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,6 @@ const {
|
|||||||
Message, // eslint-disable-line no-unused-vars
|
Message, // eslint-disable-line no-unused-vars
|
||||||
MessageEmbed
|
MessageEmbed
|
||||||
} = require('discord.js');
|
} = require('discord.js');
|
||||||
const { footer } = require('../utils/discord');
|
|
||||||
const { letters } = require('../utils/emoji');
|
const { letters } = require('../utils/emoji');
|
||||||
const { wait } = require('../utils');
|
const { wait } = require('../utils');
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ module.exports = class NewCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const editOrSend = async (msg, content) => {
|
const editOrSend = async (msg, content) => {
|
||||||
@ -57,12 +56,16 @@ module.exports = class NewCommand extends Command {
|
|||||||
if (tickets.count >= cat_row.max_per_member) {
|
if (tickets.count >= cat_row.max_per_member) {
|
||||||
if (cat_row.max_per_member === 1) {
|
if (cat_row.max_per_member === 1) {
|
||||||
response = await editOrSend(response,
|
response = await editOrSend(response,
|
||||||
new MessageEmbed()
|
{
|
||||||
.setColor(settings.error_colour)
|
embeds: [
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.new.response.has_a_ticket.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.new.response.has_a_ticket.description', tickets.rows[0].id))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setTitle(i18n('commands.new.response.has_a_ticket.title'))
|
||||||
|
.setDescription(i18n('commands.new.response.has_a_ticket.description', tickets.rows[0].id))
|
||||||
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const list = tickets.rows.map(row => {
|
const list = tickets.rows.map(row => {
|
||||||
@ -75,33 +78,45 @@ module.exports = class NewCommand extends Command {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
response = await editOrSend(response,
|
response = await editOrSend(response,
|
||||||
new MessageEmbed()
|
{
|
||||||
.setColor(settings.error_colour)
|
embeds: [
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.new.response.max_tickets.title', tickets.count))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.new.response.max_tickets.description', settings.command_prefix, list.join('\n')))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setTitle(i18n('commands.new.response.max_tickets.title', tickets.count))
|
||||||
|
.setDescription(i18n('commands.new.response.max_tickets.description', settings.command_prefix, list.join('\n')))
|
||||||
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args);
|
const t_row = await this.client.tickets.create(message.guild.id, message.author.id, cat_row.id, args);
|
||||||
response = await editOrSend(response,
|
response = await editOrSend(response,
|
||||||
new MessageEmbed()
|
{
|
||||||
.setColor(settings.success_colour)
|
embeds: [
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.new.response.created.title'))
|
.setColor(settings.success_colour)
|
||||||
.setDescription(i18n('commands.new.response.created.description', `<#${t_row.id}>`))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setTitle(i18n('commands.new.response.created.title'))
|
||||||
|
.setDescription(i18n('commands.new.response.created.description', `<#${t_row.id}>`))
|
||||||
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
response = await editOrSend(response,
|
response = await editOrSend(response,
|
||||||
new MessageEmbed()
|
{
|
||||||
.setColor(settings.error_colour)
|
embeds: [
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.new.response.error.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(error.message)
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setTitle(i18n('commands.new.response.error.title'))
|
||||||
|
.setDescription(error.message)
|
||||||
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,39 +134,45 @@ module.exports = class NewCommand extends Command {
|
|||||||
const categories = await this.client.db.models.Category.findAndCountAll({ where: { guild: message.guild.id } });
|
const categories = await this.client.db.models.Category.findAndCountAll({ where: { guild: message.guild.id } });
|
||||||
|
|
||||||
if (categories.count === 0) {
|
if (categories.count === 0) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setColor(settings.error_colour)
|
||||||
.setTitle(i18n('commands.new.response.no_categories.title'))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.new.response.no_categories.description'))
|
.setTitle(i18n('commands.new.response.no_categories.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.new.response.no_categories.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
} else if (categories.count === 1) {
|
} else if (categories.count === 1) {
|
||||||
create(categories.rows[0]); // skip the category selection
|
create(categories.rows[0]); // skip the category selection
|
||||||
} else {
|
} else {
|
||||||
const letters_array = Object.values(letters); // convert the A-Z emoji object to an array
|
const letters_array = Object.values(letters); // convert the A-Z emoji object to an array
|
||||||
const category_list = categories.rows.map((category, i) => `${letters_array[i]} » ${category.name}`); // list category names with an A-Z emoji
|
const category_list = categories.rows.map((category, i) => `${letters_array[i]} » ${category.name}`); // list category names with an A-Z emoji
|
||||||
const collector_message = await message.channel.send(
|
const collector_message = await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setColor(settings.colour)
|
||||||
.setTitle(i18n('commands.new.response.select_category.title'))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.new.response.select_category.description', category_list.join('\n')))
|
.setTitle(i18n('commands.new.response.select_category.title'))
|
||||||
.setFooter(footer(settings.footer, i18n('collector_expires_in', 30)), message.guild.iconURL())
|
.setDescription(i18n('commands.new.response.select_category.description', category_list.join('\n')))
|
||||||
);
|
.setFooter(this.client.utils.footer(settings.footer, i18n('collector_expires_in', 30)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
for (const i in categories.rows) {
|
for (const i in categories.rows) {
|
||||||
collector_message.react(letters_array[i]); // add the correct number of letter reactions
|
collector_message.react(letters_array[i]); // add the correct number of letter reactions
|
||||||
await wait(1000); // 1 reaction per second rate-limit
|
await wait(1000); // 1 reaction per second rate-limit
|
||||||
}
|
}
|
||||||
|
|
||||||
const collector_filter = (reaction, user) => {
|
const filter = (reaction, user) => {
|
||||||
const allowed = letters_array.slice(0, categories.count); // get the first x letters of the emoji array
|
const allowed = letters_array.slice(0, categories.count); // get the first x letters of the emoji array
|
||||||
return user.id === message.author.id && allowed.includes(reaction.emoji.name);
|
return user.id === message.author.id && allowed.includes(reaction.emoji.name);
|
||||||
};
|
};
|
||||||
|
const collector = collector_message.createReactionCollector({
|
||||||
const collector = collector_message.createReactionCollector(collector_filter, { time: 30000 });
|
filter,
|
||||||
|
time: 30000
|
||||||
|
});
|
||||||
|
|
||||||
collector.on('collect', async reaction => {
|
collector.on('collect', async reaction => {
|
||||||
collector.stop();
|
collector.stop();
|
||||||
@ -168,14 +189,16 @@ module.exports = class NewCommand extends Command {
|
|||||||
collector.on('end', async collected => {
|
collector.on('end', async collected => {
|
||||||
if (collected.size === 0) {
|
if (collected.size === 0) {
|
||||||
await collector_message.reactions.removeAll();
|
await collector_message.reactions.removeAll();
|
||||||
await collector_message.edit(
|
await collector_message.edit({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setColor(settings.error_colour)
|
||||||
.setTitle(i18n('commands.new.response.select_category_timeout.title'))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.new.response.select_category_timeout.description'))
|
.setTitle(i18n('commands.new.response.select_category_timeout.title'))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
.setDescription(i18n('commands.new.response.select_category_timeout.description'))
|
||||||
);
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await collector_message
|
await collector_message
|
||||||
.delete()
|
.delete()
|
||||||
|
@ -69,7 +69,7 @@ module.exports = class PanelCommand extends Command {
|
|||||||
const arg_emoji = this.args[2].name;
|
const arg_emoji = this.args[2].name;
|
||||||
const arg_categories = this.args[3].name;
|
const arg_categories = this.args[3].name;
|
||||||
|
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
if (!args[arg_emoji]) args[arg_emoji] = [];
|
if (!args[arg_emoji]) args[arg_emoji] = [];
|
||||||
@ -87,13 +87,15 @@ module.exports = class PanelCommand extends Command {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (invalid_category) {
|
if (invalid_category) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.panel.response.invalid_category.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.panel.response.invalid_category.description'))
|
.setTitle(i18n('commands.panel.response.invalid_category.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.panel.response.invalid_category.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let panel_channel,
|
let panel_channel,
|
||||||
@ -124,23 +126,25 @@ module.exports = class PanelCommand extends Command {
|
|||||||
position: 1,
|
position: 1,
|
||||||
rateLimitPerUser: 30,
|
rateLimitPerUser: 30,
|
||||||
reason: `${message.author.tag} created a new reaction-less panel`,
|
reason: `${message.author.tag} created a new reaction-less panel`,
|
||||||
type: 'text'
|
type: 'GUILD_TEXT'
|
||||||
});
|
});
|
||||||
|
|
||||||
embed.setDescription(args[arg_description]);
|
embed.setDescription(args[arg_description]);
|
||||||
panel_message = await panel_channel.send(embed);
|
panel_message = await panel_channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
this.client.log.info(`${message.author.tag} has created a new reaction-less panel`);
|
this.client.log.info(`${message.author.tag} has created a new reaction-less panel`);
|
||||||
} else {
|
} else {
|
||||||
if (args[arg_categories].length !== args[arg_emoji].length) {
|
if (args[arg_categories].length !== args[arg_emoji].length) {
|
||||||
// send error
|
// send error
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.panel.response.mismatch.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.panel.response.mismatch.description'))
|
.setTitle(i18n('commands.panel.response.mismatch.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.panel.response.mismatch.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
panel_channel = await message.guild.channels.create('create-a-ticket', {
|
panel_channel = await message.guild.channels.create('create-a-ticket', {
|
||||||
permissionOverwrites: [
|
permissionOverwrites: [
|
||||||
@ -156,7 +160,7 @@ module.exports = class PanelCommand extends Command {
|
|||||||
],
|
],
|
||||||
position: 1,
|
position: 1,
|
||||||
reason: `${message.author.tag} created a new panel`,
|
reason: `${message.author.tag} created a new panel`,
|
||||||
type: 'text'
|
type: 'GUILD_TEXT'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (args[arg_emoji].length === 1) {
|
if (args[arg_emoji].length === 1) {
|
||||||
@ -164,7 +168,7 @@ module.exports = class PanelCommand extends Command {
|
|||||||
categories_map = {};
|
categories_map = {};
|
||||||
categories_map[args[arg_emoji][0]] = args[arg_categories][0];
|
categories_map[args[arg_emoji][0]] = args[arg_categories][0];
|
||||||
embed.setDescription(args[arg_description]);
|
embed.setDescription(args[arg_description]);
|
||||||
panel_message = await panel_channel.send(embed);
|
panel_message = await panel_channel.send({ embeds: [embed] });
|
||||||
await panel_message.react(args[arg_emoji][0]);
|
await panel_message.react(args[arg_emoji][0]);
|
||||||
} else {
|
} else {
|
||||||
// multi category
|
// multi category
|
||||||
@ -183,7 +187,11 @@ module.exports = class PanelCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
embed.setDescription(args[arg_description] + '\n' + description);
|
embed.setDescription(args[arg_description] + '\n' + description);
|
||||||
panel_message = await panel_channel.send(embed);
|
panel_message = await panel_channel.send({
|
||||||
|
embeds: [
|
||||||
|
embed
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
for (const emoji of args[arg_emoji]) {
|
for (const emoji of args[arg_emoji]) {
|
||||||
await panel_message.react(emoji);
|
await panel_message.react(emoji);
|
||||||
@ -196,7 +204,7 @@ module.exports = class PanelCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.channel.send(`✅ ${panel_channel}`);
|
message.channel.send({ content: `✅ ${panel_channel}` });
|
||||||
|
|
||||||
await this.client.db.models.Panel.create({
|
await this.client.db.models.Panel.create({
|
||||||
categories: categories_map,
|
categories: categories_map,
|
||||||
|
@ -36,63 +36,73 @@ module.exports = class RemoveCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const ticket = message.mentions.channels.first() ?? message.channel;
|
const ticket = message.mentions.channels.first() ?? message.channel;
|
||||||
const t_row = await this.client.tickets.resolve(ticket.id, message.guild.id);
|
const t_row = await this.client.tickets.resolve(ticket.id, message.guild.id);
|
||||||
|
|
||||||
if (!t_row) {
|
if (!t_row) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.remove.response.not_a_ticket.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.remove.response.not_a_ticket.description'))
|
.setTitle(i18n('commands.remove.response.not_a_ticket.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.remove.response.not_a_ticket.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const member = message.mentions.members.first() ?? message.guild.members.cache.get(args);
|
const member = message.mentions.members.first() ?? message.guild.members.cache.get(args);
|
||||||
|
|
||||||
if (!member) {
|
if (!member) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.remove.response.no_member.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.remove.response.no_member.description'))
|
.setTitle(i18n('commands.remove.response.no_member.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.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()) {
|
if (t_row.creator !== message.author.id && !await this.client.utils.isStaff(message.member)) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.remove.response.no_permission.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.remove.response.no_permission.description'))
|
.setTitle(i18n('commands.remove.response.no_permission.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.remove.response.no_permission.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.channel.id !== ticket.id) {
|
if (message.channel.id !== ticket.id) {
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.success_colour)
|
||||||
.setTitle(i18n('commands.remove.response.removed.title'))
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.remove.response.removed.description', member.toString(), ticket.toString()))
|
.setTitle(i18n('commands.remove.response.removed.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.remove.response.removed.description', member.toString(), ticket.toString()))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await ticket.send(
|
await ticket.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.colour)
|
||||||
.setTitle(i18n('ticket.member_removed.title'))
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.setDescription(i18n('ticket.member_removed.description', member.toString(), message.author.toString()))
|
.setTitle(i18n('ticket.member_removed.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('ticket.member_removed.description', member.toString(), message.author.toString()))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
await ticket.permissionOverwrites
|
await ticket.permissionOverwrites
|
||||||
.get(member.user.id)
|
.get(member.user.id)
|
||||||
@ -100,4 +110,4 @@ module.exports = class RemoveCommand extends Command {
|
|||||||
|
|
||||||
this.client.log.info(`${message.author.tag} removed ${member.user.tag} from ${ticket.id}`);
|
this.client.log.info(`${message.author.tag} removed ${member.user.tag} from ${ticket.id}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ module.exports = class SettingsCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message) {
|
async execute(message) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const attachments = [...message.attachments.values()];
|
const attachments = [...message.attachments.values()];
|
||||||
@ -48,7 +48,7 @@ module.exports = class SettingsCommand extends Command {
|
|||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
this.client.log.warn('Settings validation error');
|
this.client.log.warn('Settings validation error');
|
||||||
return await message.channel.send(i18n('commands.settings.response.invalid', errors.map(error => `\`${error.stack}\``).join(',\n')));
|
return await message.channel.send({ content: i18n('commands.settings.response.invalid', errors.map(error => `\`${error.stack}\``).join(',\n')) });
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.colour = data.colour;
|
settings.colour = data.colour;
|
||||||
@ -84,7 +84,7 @@ module.exports = class SettingsCommand extends Command {
|
|||||||
if (cat_channel.name !== c.name) await cat_channel.setName(c.name, `Tickets category updated by ${message.author.tag}`);
|
if (cat_channel.name !== c.name) await cat_channel.setName(c.name, `Tickets category updated by ${message.author.tag}`);
|
||||||
|
|
||||||
for (const r of c.roles) {
|
for (const r of c.roles) {
|
||||||
await cat_channel.updateOverwrite(r, {
|
await cat_channel.permissionOverwrites.edit(r, {
|
||||||
ATTACH_FILES: true,
|
ATTACH_FILES: true,
|
||||||
READ_MESSAGE_HISTORY: true,
|
READ_MESSAGE_HISTORY: true,
|
||||||
SEND_MESSAGES: true,
|
SEND_MESSAGES: true,
|
||||||
@ -114,7 +114,7 @@ module.exports = class SettingsCommand extends Command {
|
|||||||
],
|
],
|
||||||
position: 1,
|
position: 1,
|
||||||
reason: `Tickets category created by ${message.author.tag}`,
|
reason: `Tickets category created by ${message.author.tag}`,
|
||||||
type: 'category'
|
type: 'GUILD_CATEGORY'
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.client.db.models.Category.create({
|
await this.client.db.models.Category.create({
|
||||||
@ -149,7 +149,7 @@ module.exports = class SettingsCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.client.log.success(`Updated guild settings for "${message.guild.name}"`);
|
this.client.log.success(`Updated guild settings for "${message.guild.name}"`);
|
||||||
return await message.channel.send(i18n('commands.settings.response.updated'));
|
return await message.channel.send({ content: i18n('commands.settings.response.updated') });
|
||||||
} else {
|
} else {
|
||||||
// upload settings as json to be edited
|
// upload settings as json to be edited
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ module.exports = class StatsCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message) {
|
async execute(message) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const messages = await this.client.db.models.Message.findAndCountAll();
|
const messages = await this.client.db.models.Message.findAndCountAll();
|
||||||
@ -62,19 +62,25 @@ module.exports = class StatsCommand extends Command {
|
|||||||
|
|
||||||
if (stats.messages) guild_embed.addField(i18n('commands.stats.fields.messages'), stats.messages, true);
|
if (stats.messages) guild_embed.addField(i18n('commands.stats.fields.messages'), stats.messages, true);
|
||||||
|
|
||||||
await message.channel.send(guild_embed);
|
await message.channel.send({
|
||||||
|
embeds: [
|
||||||
|
guild_embed
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
if (this.client.guilds.cache.size > 1) {
|
if (this.client.guilds.cache.size > 1) {
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.stats.response.global.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.stats.response.global.description'))
|
.setTitle(i18n('commands.stats.response.global.title'))
|
||||||
.addField(i18n('commands.stats.fields.tickets'), stats.tickets, true)
|
.setDescription(i18n('commands.stats.response.global.description'))
|
||||||
.addField(i18n('commands.stats.fields.response_time.title'), i18n('commands.stats.fields.response_time.minutes', stats.response_time), true)
|
.addField(i18n('commands.stats.fields.tickets'), stats.tickets, true)
|
||||||
.addField(i18n('commands.stats.fields.messages'), stats.messages, true)
|
.addField(i18n('commands.stats.fields.response_time.title'), i18n('commands.stats.fields.response_time.minutes', stats.response_time), true)
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.addField(i18n('commands.stats.fields.messages'), stats.messages, true)
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,7 @@ module.exports = class SurveyCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const survey = await this.client.db.models.Survey.findOne({
|
const survey = await this.client.db.models.Survey.findOne({
|
||||||
@ -90,13 +90,15 @@ module.exports = class SurveyCommand extends Command {
|
|||||||
const surveys = await this.client.db.models.Survey.findAll({ where: { guild: message.guild.id } });
|
const surveys = await this.client.db.models.Survey.findAll({ where: { guild: message.guild.id } });
|
||||||
|
|
||||||
const list = surveys.map(s => `❯ **\`${s.name}\`**`);
|
const list = surveys.map(s => `❯ **\`${s.name}\`**`);
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.survey.response.list.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(list.join('\n'))
|
.setTitle(i18n('commands.survey.response.list.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(list.join('\n'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ module.exports = class TagCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
||||||
@ -52,13 +52,15 @@ module.exports = class TagCommand extends Command {
|
|||||||
const requires_ticket = placeholders.some(p => p.startsWith('ticket.'));
|
const requires_ticket = placeholders.some(p => p.startsWith('ticket.'));
|
||||||
|
|
||||||
if (requires_ticket && !t_row) {
|
if (requires_ticket && !t_row) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.tag.response.not_a_ticket.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.tag.response.not_a_ticket.description'))
|
.setTitle(i18n('commands.tag.response.not_a_ticket.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.tag.response.not_a_ticket.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const expected = placeholders
|
const expected = placeholders
|
||||||
@ -72,13 +74,15 @@ module.exports = class TagCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
args = parseArgs(expected, { argv: argv(args) });
|
args = parseArgs(expected, { argv: argv(args) });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.tag.response.error'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(`\`\`\`${error.message}\`\`\``)
|
.setTitle(i18n('commands.tag.response.error'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(`\`\`\`${error.message}\`\`\``)
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args = {};
|
args = {};
|
||||||
@ -87,13 +91,15 @@ module.exports = class TagCommand extends Command {
|
|||||||
for (const p of expected) {
|
for (const p of expected) {
|
||||||
if (!args[p.name]) {
|
if (!args[p.name]) {
|
||||||
const list = expected.map(p => `\`${p.name}\``);
|
const list = expected.map(p => `\`${p.name}\``);
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.tag.response.error'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.tag.response.missing', list.join(', ')))
|
.setTitle(i18n('commands.tag.response.error'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.tag.response.missing', list.join(', ')))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,21 +110,25 @@ module.exports = class TagCommand extends Command {
|
|||||||
|
|
||||||
// note that this regex is slightly different to the other
|
// note that this regex is slightly different to the other
|
||||||
const text = tag.replace(/(?<!\\){{1,2}\s?:?([A-Za-z0-9._]+)\s?(?<!\\)}{1,2}/gi, (_$, $1) => this.client.i18n.resolve(args, $1));
|
const text = tag.replace(/(?<!\\){{1,2}\s?:?([A-Za-z0-9._]+)\s?(?<!\\)}{1,2}/gi, (_$, $1) => this.client.i18n.resolve(args, $1));
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setDescription(text)
|
.setColor(settings.colour)
|
||||||
);
|
.setDescription(text)
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const list = Object.keys(settings.tags).map(t => `❯ **\`${t}\`**`);
|
const list = Object.keys(settings.tags).map(t => `❯ **\`${t}\`**`);
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.tag.response.list.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(list.join('\n'))
|
.setTitle(i18n('commands.tag.response.list.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(list.join('\n'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -30,19 +30,21 @@ module.exports = class TopicCommand extends Command {
|
|||||||
* @returns {Promise<void|any>}
|
* @returns {Promise<void|any>}
|
||||||
*/
|
*/
|
||||||
async execute(message, args) {
|
async execute(message, args) {
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
||||||
|
|
||||||
if (!t_row) {
|
if (!t_row) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('commands.topic.response.not_a_ticket.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('commands.topic.response.not_a_ticket.description'))
|
.setTitle(i18n('commands.topic.response.not_a_ticket.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.topic.response.not_a_ticket.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await t_row.update({ topic: this.client.cryptr.encrypt(args) });
|
await t_row.update({ topic: this.client.cryptr.encrypt(args) });
|
||||||
@ -56,24 +58,28 @@ module.exports = class TopicCommand extends Command {
|
|||||||
.replace(/{+\s?(tag|ping|mention)?\s?}+/gi, member.user.toString());
|
.replace(/{+\s?(tag|ping|mention)?\s?}+/gi, member.user.toString());
|
||||||
const opening_message = await message.channel.messages.fetch(t_row.opening_message);
|
const opening_message = await message.channel.messages.fetch(t_row.opening_message);
|
||||||
|
|
||||||
await opening_message.edit(
|
await opening_message.edit({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.colour)
|
||||||
.setDescription(description)
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.addField(i18n('ticket.opening_message.fields.topic'), args)
|
.setDescription(description)
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.addField(i18n('ticket.opening_message.fields.topic'), args)
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setColor(settings.success_colour)
|
||||||
.setTitle(i18n('commands.topic.response.changed.title'))
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setDescription(i18n('commands.topic.response.changed.description'))
|
.setTitle(i18n('commands.topic.response.changed.title'))
|
||||||
.setFooter(settings.footer, message.guild.iconURL())
|
.setDescription(i18n('commands.topic.response.changed.description'))
|
||||||
);
|
.setFooter(settings.footer, message.guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
this.client.log.info(`${message.author.tag} changed the topic of ${message.channel.id}`);
|
this.client.log.info(`${message.author.tag} changed the topic of ${message.channel.id}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
25
src/index.js
25
src/index.js
@ -24,8 +24,9 @@
|
|||||||
|
|
||||||
process.title = 'Discord Tickets';
|
process.title = 'Discord Tickets';
|
||||||
|
|
||||||
const node_version = Number(process.versions.node.split('.')[0]);
|
const min_node_version = '16.6.0';
|
||||||
if (node_version < 14) return console.log(`\x07Error: Discord Tickets does not work on Node v${node_version}. Please upgrade to v14 or above.`);
|
const semver = require('semver');
|
||||||
|
if (semver.lt(process.versions.node, min_node_version)) return console.log(`\x07Error: Discord Tickets does not work on Node v${process.versions.node}; please upgrade to v${min_node_version} or above.`);
|
||||||
|
|
||||||
const leeks = require('leeks.js');
|
const leeks = require('leeks.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@ -82,7 +83,7 @@ process.on('unhandledRejection', error => {
|
|||||||
log.error(error);
|
log.error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const { selectPresence } = require('./utils/discord');
|
const DiscordUtils = require('./utils/discord');
|
||||||
const Cryptr = require('cryptr');
|
const Cryptr = require('cryptr');
|
||||||
const I18n = require('@eartharoid/i18n');
|
const I18n = require('@eartharoid/i18n');
|
||||||
const ListenerLoader = require('./modules/listeners/loader');
|
const ListenerLoader = require('./modules/listeners/loader');
|
||||||
@ -92,14 +93,12 @@ const TicketManager = require('./modules/tickets/manager');
|
|||||||
|
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
require('./modules/structures')(); // load extended structures before creating the client
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Client,
|
Client,
|
||||||
Intents
|
Intents
|
||||||
} = require('discord.js');
|
} = require('discord.js');
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const FastifyLogger = require('leekslazylogger-fastify');
|
const Logger = require('leekslazylogger');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Discord client
|
* The Discord client
|
||||||
@ -109,13 +108,18 @@ const FastifyLogger = require('leekslazylogger-fastify');
|
|||||||
class Bot extends Client {
|
class Bot extends Client {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
|
intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
Intents.FLAGS.GUILD_MEMBERS,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
|
||||||
|
],
|
||||||
partials: [
|
partials: [
|
||||||
'CHANNEL',
|
'CHANNEL',
|
||||||
'MESSAGE',
|
'MESSAGE',
|
||||||
'REACTION'
|
'REACTION'
|
||||||
],
|
],
|
||||||
presence: selectPresence(),
|
presence: DiscordUtils.selectPresence()
|
||||||
ws: { intents: Intents.NON_PRIVILEGED }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -124,7 +128,7 @@ class Bot extends Client {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A [leekslazylogger](https://logger.eartharoid.me) instance
|
* A [leekslazylogger](https://logger.eartharoid.me) instance
|
||||||
* @type {FastifyLogger}
|
* @type {Logger}
|
||||||
*/
|
*/
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
|
||||||
@ -169,6 +173,9 @@ class Bot extends Client {
|
|||||||
this.plugins = new PluginManager(this);
|
this.plugins = new PluginManager(this);
|
||||||
this.plugins.load(); // load plugins
|
this.plugins.load(); // load plugins
|
||||||
|
|
||||||
|
/** Some utility methods */
|
||||||
|
this.utils = new DiscordUtils(this);
|
||||||
|
|
||||||
this.log.info('Connecting to Discord API...');
|
this.log.info('Connecting to Discord API...');
|
||||||
|
|
||||||
this.login();
|
this.login();
|
||||||
|
@ -7,6 +7,6 @@ module.exports = class GuildDeleteEventListener extends EventListener {
|
|||||||
|
|
||||||
async execute(guild) {
|
async execute(guild) {
|
||||||
this.client.log.info(`Removed from "${guild.name}"`);
|
this.client.log.info(`Removed from "${guild.name}"`);
|
||||||
// await guild.deleteSettings();
|
await guild.deleteSettings();
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,17 +1,16 @@
|
|||||||
const EventListener = require('../modules/listeners/listener');
|
const EventListener = require('../modules/listeners/listener');
|
||||||
|
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const { footer } = require('../utils/discord');
|
|
||||||
|
|
||||||
module.exports = class MessageEventListener extends EventListener {
|
module.exports = class MessageCreateEventListener extends EventListener {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, { event: 'message' });
|
super(client, { event: 'messageCreate' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(message) {
|
async execute(message) {
|
||||||
if (!message.guild) return;
|
if (!message.guild) return;
|
||||||
|
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: message.channel.id } });
|
||||||
@ -53,11 +52,11 @@ module.exports = class MessageEventListener extends EventListener {
|
|||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle(i18n('commands.new.response.has_a_ticket.title'))
|
.setTitle(i18n('commands.new.response.has_a_ticket.title'))
|
||||||
.setDescription(i18n('commands.new.response.has_a_ticket.description', tickets.rows[0].id))
|
.setDescription(i18n('commands.new.response.has_a_ticket.description', tickets.rows[0].id))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL());
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL());
|
||||||
try {
|
try {
|
||||||
response = await message.author.send(embed);
|
response = await message.author.send({ embeds: [embed] });
|
||||||
} catch {
|
} catch {
|
||||||
response = await message.channel.send(embed);
|
response = await message.channel.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const list = tickets.rows.map(row => {
|
const list = tickets.rows.map(row => {
|
||||||
@ -74,11 +73,11 @@ module.exports = class MessageEventListener extends EventListener {
|
|||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle(i18n('commands.new.response.max_tickets.title', tickets.count))
|
.setTitle(i18n('commands.new.response.max_tickets.title', tickets.count))
|
||||||
.setDescription(i18n('commands.new.response.max_tickets.description', settings.command_prefix, list.join('\n')))
|
.setDescription(i18n('commands.new.response.max_tickets.description', settings.command_prefix, list.join('\n')))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.author.iconURL());
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.author.iconURL());
|
||||||
try {
|
try {
|
||||||
response = await message.author.send(embed);
|
response = await message.author.send({ embeds: [embed] });
|
||||||
} catch {
|
} catch {
|
||||||
response = await message.channel.send(embed);
|
response = await message.channel.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -90,11 +89,11 @@ module.exports = class MessageEventListener extends EventListener {
|
|||||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||||
.setTitle(i18n('commands.new.response.error.title'))
|
.setTitle(i18n('commands.new.response.error.title'))
|
||||||
.setDescription(error.message)
|
.setDescription(error.message)
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL());
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), message.guild.iconURL());
|
||||||
try {
|
try {
|
||||||
response = await message.author.send(embed);
|
response = await message.author.send({ embeds: [embed] });
|
||||||
} catch {
|
} catch {
|
||||||
response = await message.channel.send(embed);
|
response = await message.channel.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ module.exports = class MessageDeleteEventListener extends EventListener {
|
|||||||
async execute(message) {
|
async execute(message) {
|
||||||
if (!message.guild) return;
|
if (!message.guild) return;
|
||||||
|
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
|
|
||||||
if (settings.log_messages && !message.system) this.client.tickets.archives.deleteMessage(message); // mark the message as deleted in the database (if it exists)
|
if (settings.log_messages && !message.system) this.client.tickets.archives.deleteMessage(message); // mark the message as deleted in the database (if it exists)
|
||||||
}
|
}
|
||||||
|
@ -1,89 +1,90 @@
|
|||||||
const EventListener = require('../modules/listeners/listener');
|
const EventListener = require('../modules/listeners/listener');
|
||||||
|
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const { footer } = require('../utils/discord');
|
|
||||||
|
|
||||||
module.exports = class MessageReactionAddEventListener extends EventListener {
|
module.exports = class MessageReactionAddEventListener extends EventListener {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, { event: 'messageReactionAdd' });
|
super(client, { event: 'messageReactionAdd' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(r, u) {
|
async execute(reaction, user) {
|
||||||
|
|
||||||
if (r.partial) {
|
if (reaction.partial) {
|
||||||
try {
|
try {
|
||||||
await r.fetch();
|
await reaction.fetch();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.log.error(err);
|
return this.client.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u.partial) {
|
if (user.partial) {
|
||||||
try {
|
try {
|
||||||
await u.fetch();
|
await user.fetch();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.log.error(err);
|
return this.client.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u.id === this.client.user.id) return;
|
if (user.id === this.client.user.id) return;
|
||||||
|
|
||||||
const guild = r.message.guild;
|
const guild = reaction.message.guild;
|
||||||
if (!guild) return;
|
if (!guild) return;
|
||||||
|
|
||||||
const settings = await guild.getSettings();
|
const settings = await this.client.utils.getSettings(guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const channel = r.message.channel;
|
const channel = reaction.message.channel;
|
||||||
const member = await guild.members.fetch(u.id);
|
const member = await guild.members.fetch(user.id);
|
||||||
|
|
||||||
if (settings.blacklist.includes(u.id)) {
|
if (settings.blacklist.includes(user.id)) {
|
||||||
return this.client.log.info(`Ignoring blacklisted member ${u.tag}`);
|
return this.client.log.info(`Ignoring blacklisted member ${user.tag}`);
|
||||||
} else {
|
} else {
|
||||||
settings.blacklist.forEach(element => {
|
settings.blacklist.forEach(element => {
|
||||||
if (guild.roles.cache.has(element) && member.roles.cache.has(element)) {
|
if (guild.roles.cache.has(element) && member.roles.cache.has(element)) {
|
||||||
return this.client.log.info(`Ignoring member ${u.tag} with blacklisted role`);
|
return this.client.log.info(`Ignoring member ${user.tag} with blacklisted role`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: channel.id } });
|
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: channel.id } });
|
||||||
|
|
||||||
if (t_row && t_row.opening_message === r.message.id) {
|
if (t_row && t_row.opening_message === reaction.message.id) {
|
||||||
if (r.emoji.name === '🙌' && await member.isStaff()) {
|
if (reaction.emoji.name === '🙌' && await this.client.utils.isStaff(member)) {
|
||||||
// ticket claiming
|
// ticket claiming
|
||||||
|
|
||||||
await t_row.update({ claimed_by: member.user.id });
|
await t_row.update({ claimed_by: member.user.id });
|
||||||
|
|
||||||
await channel.updateOverwrite(member.user.id, { VIEW_CHANNEL: true }, `Ticket claimed by ${member.user.tag}`);
|
await channel.permissionOverwrites.edit(member.user.id, { VIEW_CHANNEL: true }, `Ticket claimed by ${member.user.tag}`);
|
||||||
|
|
||||||
const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } });
|
const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } });
|
||||||
|
|
||||||
for (const role of cat_row.roles) {
|
for (const role of cat_row.roles) {
|
||||||
await channel.updateOverwrite(role, { VIEW_CHANNEL: false }, `Ticket claimed by ${member.user.tag}`);
|
await channel.permissionOverwrites.edit(role, { VIEW_CHANNEL: false }, `Ticket claimed by ${member.user.tag}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.log.info(`${member.user.tag} has claimed "${channel.name}" in "${guild.name}"`);
|
this.client.log.info(`${member.user.tag} has claimed "${channel.name}" in "${guild.name}"`);
|
||||||
|
|
||||||
await channel.send(
|
await channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.colour)
|
||||||
.setTitle(i18n('ticket.claimed.title'))
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.setDescription(i18n('ticket.claimed.description', member.toString()))
|
.setTitle(i18n('ticket.claimed.title'))
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(i18n('ticket.claimed.description', member.toString()))
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await r.users.remove(u.id);
|
await reaction.users.remove(user.id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const p_row = await this.client.db.models.Panel.findOne({ where: { message: r.message.id } });
|
const p_row = await this.client.db.models.Panel.findOne({ where: { message: reaction.message.id } });
|
||||||
|
|
||||||
if (p_row && typeof p_row.categories !== 'string') {
|
if (p_row && typeof p_row.categories !== 'string') {
|
||||||
// panels
|
// panels
|
||||||
await r.users.remove(u.id);
|
await reaction.users.remove(user.id);
|
||||||
|
|
||||||
const category_id = p_row.categories[r.emoji.name];
|
const category_id = p_row.categories[reaction.emoji.name];
|
||||||
if (!category_id) return;
|
if (!category_id) return;
|
||||||
|
|
||||||
const cat_row = await this.client.db.models.Category.findOne({ where: { id: category_id } });
|
const cat_row = await this.client.db.models.Category.findOne({ where: { id: category_id } });
|
||||||
@ -91,7 +92,7 @@ module.exports = class MessageReactionAddEventListener extends EventListener {
|
|||||||
const tickets = await this.client.db.models.Ticket.findAndCountAll({
|
const tickets = await this.client.db.models.Ticket.findAndCountAll({
|
||||||
where: {
|
where: {
|
||||||
category: cat_row.id,
|
category: cat_row.id,
|
||||||
creator: u.id,
|
creator: user.id,
|
||||||
open: true
|
open: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -102,14 +103,14 @@ module.exports = class MessageReactionAddEventListener extends EventListener {
|
|||||||
if (cat_row.max_per_member === 1) {
|
if (cat_row.max_per_member === 1) {
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(settings.error_colour)
|
.setColor(settings.error_colour)
|
||||||
.setAuthor(u.username, u.displayAvatarURL())
|
.setAuthor(user.username, user.displayAvatarURL())
|
||||||
.setTitle(i18n('commands.new.response.has_a_ticket.title'))
|
.setTitle(i18n('commands.new.response.has_a_ticket.title'))
|
||||||
.setDescription(i18n('commands.new.response.has_a_ticket.description', tickets.rows[0].id))
|
.setDescription(i18n('commands.new.response.has_a_ticket.description', tickets.rows[0].id))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), guild.iconURL());
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), guild.iconURL());
|
||||||
try {
|
try {
|
||||||
response = await u.send(embed);
|
response = await user.send({ embeds: [embed] });
|
||||||
} catch {
|
} catch {
|
||||||
response = await channel.send(embed);
|
response = await channel.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const list = tickets.rows.map(row => {
|
const list = tickets.rows.map(row => {
|
||||||
@ -123,30 +124,30 @@ module.exports = class MessageReactionAddEventListener extends EventListener {
|
|||||||
});
|
});
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(settings.error_colour)
|
.setColor(settings.error_colour)
|
||||||
.setAuthor(u.username, u.displayAvatarURL())
|
.setAuthor(user.username, user.displayAvatarURL())
|
||||||
.setTitle(i18n('commands.new.response.max_tickets.title', tickets.count))
|
.setTitle(i18n('commands.new.response.max_tickets.title', tickets.count))
|
||||||
.setDescription(i18n('commands.new.response.max_tickets.description', settings.command_prefix, list.join('\n')))
|
.setDescription(i18n('commands.new.response.max_tickets.description', settings.command_prefix, list.join('\n')))
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), u.iconURL());
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), user.iconURL());
|
||||||
try {
|
try {
|
||||||
response = await u.send(embed);
|
response = await user.send({ embeds: [embed] });
|
||||||
} catch {
|
} catch {
|
||||||
response = await channel.send(embed);
|
response = await channel.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await this.client.tickets.create(guild.id, u.id, cat_row.id);
|
await this.client.tickets.create(guild.id, user.id, cat_row.id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(settings.error_colour)
|
.setColor(settings.error_colour)
|
||||||
.setAuthor(u.username, u.displayAvatarURL())
|
.setAuthor(user.username, user.displayAvatarURL())
|
||||||
.setTitle(i18n('commands.new.response.error.title'))
|
.setTitle(i18n('commands.new.response.error.title'))
|
||||||
.setDescription(error.message)
|
.setDescription(error.message)
|
||||||
.setFooter(footer(settings.footer, i18n('message_will_be_deleted_in', 15)), guild.iconURL());
|
.setFooter(this.client.utils.footer(settings.footer, i18n('message_will_be_deleted_in', 15)), guild.iconURL());
|
||||||
try {
|
try {
|
||||||
response = await u.send(embed);
|
response = await user.send({ embeds: [embed] });
|
||||||
} catch {
|
} catch {
|
||||||
response = await channel.send(embed);
|
response = await channel.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,39 +7,39 @@ module.exports = class MessageReactionRemoveEventListener extends EventListener
|
|||||||
super(client, { event: 'messageReactionRemove' });
|
super(client, { event: 'messageReactionRemove' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(r, u) {
|
async execute(reaction, user) {
|
||||||
// release (unclaim) ticket
|
// release (unclaim) ticket
|
||||||
if (r.partial) {
|
if (reaction.partial) {
|
||||||
try {
|
try {
|
||||||
await r.fetch();
|
await reaction.fetch();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.log.error(err);
|
return this.client.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u.partial) {
|
if (user.partial) {
|
||||||
try {
|
try {
|
||||||
await u.fetch();
|
await user.fetch();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.log.error(err);
|
return this.client.log.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u.id === this.client.user.id) return;
|
if (user.id === this.client.user.id) return;
|
||||||
|
|
||||||
const guild = r.message.guild;
|
const guild = reaction.message.guild;
|
||||||
if (!guild) return;
|
if (!guild) return;
|
||||||
|
|
||||||
const settings = await guild.getSettings();
|
const settings = await this.client.utils.getSettings(guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
const channel = r.message.channel;
|
const channel = reaction.message.channel;
|
||||||
const member = await guild.members.fetch(u.id);
|
const member = await guild.members.fetch(user.id);
|
||||||
|
|
||||||
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: channel.id } });
|
const t_row = await this.client.db.models.Ticket.findOne({ where: { id: channel.id } });
|
||||||
|
|
||||||
if (t_row && t_row.opening_message === r.message.id) {
|
if (t_row && t_row.opening_message === reaction.message.id) {
|
||||||
if (r.emoji.name === '🙌' && await member.isStaff()) {
|
if (reaction.emoji.name === '🙌' && await this.client.utils.isStaff(member)) {
|
||||||
// ticket claiming
|
// ticket claiming
|
||||||
|
|
||||||
await t_row.update({ claimed_by: null });
|
await t_row.update({ claimed_by: null });
|
||||||
@ -51,19 +51,21 @@ module.exports = class MessageReactionRemoveEventListener extends EventListener
|
|||||||
const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } });
|
const cat_row = await this.client.db.models.Category.findOne({ where: { id: t_row.category } });
|
||||||
|
|
||||||
for (const role of cat_row.roles) {
|
for (const role of cat_row.roles) {
|
||||||
await channel.updateOverwrite(role, { VIEW_CHANNEL: true }, `Ticket released by ${member.user.tag}`);
|
await channel.permissionOverwrites.edit(role, { VIEW_CHANNEL: true }, `Ticket released by ${member.user.tag}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.log.info(`${member.user.tag} has released "${channel.name}" in "${guild.name}"`);
|
this.client.log.info(`${member.user.tag} has released "${channel.name}" in "${guild.name}"`);
|
||||||
|
|
||||||
await channel.send(
|
await channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
.setColor(settings.colour)
|
||||||
.setTitle(i18n('ticket.released.title'))
|
.setAuthor(member.user.username, member.user.displayAvatarURL())
|
||||||
.setDescription(i18n('ticket.released.description', member.toString()))
|
.setTitle(i18n('ticket.released.title'))
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(i18n('ticket.released.description', member.toString()))
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ module.exports = class MessageUpdateEventListener extends EventListener {
|
|||||||
|
|
||||||
if (!newm.guild) return;
|
if (!newm.guild) return;
|
||||||
|
|
||||||
const settings = await newm.guild.getSettings();
|
const settings = await this.client.utils.getSettings(newm.guild);
|
||||||
|
|
||||||
if (settings.log_messages && !newm.system) this.client.tickets.archives.updateMessage(newm); // update the message in the database
|
if (settings.log_messages && !newm.system) this.client.tickets.archives.updateMessage(newm); // update the message in the database
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ module.exports = class ReadyEventListener extends EventListener {
|
|||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const presence = selectPresence();
|
const presence = selectPresence();
|
||||||
this.client.user.setPresence(presence);
|
this.client.user.setPresence(presence);
|
||||||
this.client.log.debug(`Updated presence: ${presence.activity.type} ${presence.activity.name}`);
|
this.client.log.debug(`Updated presence: ${presence.activities[0].type} ${presence.activities[0].name}`);
|
||||||
}, this.client.config.presence.duration * 1000);
|
}, this.client.config.presence.duration * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const { path } = require('./utils/fs');
|
const { path } = require('./utils/fs');
|
||||||
const config = require('../user/config');
|
const config = require('../user/config');
|
||||||
const Logger = require('leekslazylogger-fastify');
|
const Logger = require('leekslazylogger');
|
||||||
module.exports = new Logger({
|
module.exports = new Logger({
|
||||||
debug: config.debug,
|
debug: config.debug,
|
||||||
directory: path('./logs/'),
|
directory: path('./logs/'),
|
||||||
|
@ -122,7 +122,7 @@ module.exports = class Command {
|
|||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
*/
|
*/
|
||||||
async sendUsage(channel, alias) {
|
async sendUsage(channel, alias) {
|
||||||
const settings = await channel.guild.getSettings();
|
const settings = await this.client.utils.getSettings(channel.guild);
|
||||||
if (!alias) alias = this.name;
|
if (!alias) alias = this.name;
|
||||||
|
|
||||||
const prefix = settings.command_prefix;
|
const prefix = settings.command_prefix;
|
||||||
@ -156,7 +156,7 @@ module.exports = class Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.args.forEach(arg => addArgs(embed, arg));
|
this.args.forEach(arg => addArgs(embed, arg));
|
||||||
return await channel.send(embed);
|
return await channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ module.exports = class CommandManager {
|
|||||||
async handle(message) {
|
async handle(message) {
|
||||||
if (message.author.bot) return; // ignore self and other bots
|
if (message.author.bot) return; // ignore self and other bots
|
||||||
|
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await this.client.utils.getSettings(message.guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
const prefix = settings.command_prefix;
|
const prefix = settings.command_prefix;
|
||||||
const escaped_prefix = prefix.toLowerCase().replace(/(?=\W)/g, '\\'); // (lazy) escape every character so it can be used in a RexExp
|
const escaped_prefix = prefix.toLowerCase().replace(/(?=\W)/g, '\\'); // (lazy) escape every character so it can be used in a RexExp
|
||||||
@ -122,14 +122,16 @@ module.exports = class CommandManager {
|
|||||||
if (!bot_permissions.has(required_bot_permissions)) {
|
if (!bot_permissions.has(required_bot_permissions)) {
|
||||||
const perms = required_bot_permissions.map(p => `\`${p}\``).join(', ');
|
const perms = required_bot_permissions.map(p => `\`${p}\``).join(', ');
|
||||||
if (bot_permissions.has(['EMBED_LINKS', 'SEND_MESSAGES'])) {
|
if (bot_permissions.has(['EMBED_LINKS', 'SEND_MESSAGES'])) {
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor('ORANGE')
|
new MessageEmbed()
|
||||||
.setTitle(i18n('bot.missing_permissions.title'))
|
.setColor('ORANGE')
|
||||||
.setDescription(i18n('bot.missing_permissions.description', perms))
|
.setTitle(i18n('bot.missing_permissions.title'))
|
||||||
);
|
.setDescription(i18n('bot.missing_permissions.description', perms))
|
||||||
|
]
|
||||||
|
});
|
||||||
} else if (bot_permissions.has('SEND_MESSAGES')) {
|
} else if (bot_permissions.has('SEND_MESSAGES')) {
|
||||||
await message.channel.send('⚠️ ' + i18n('bot.missing_permissions.description', perms));
|
await message.channel.send({ content: '⚠️ ' + i18n('bot.missing_permissions.description', perms) });
|
||||||
} else if (bot_permissions.has('ADD_REACTIONS')) {
|
} else if (bot_permissions.has('ADD_REACTIONS')) {
|
||||||
await message.react('⚠️');
|
await message.react('⚠️');
|
||||||
} else {
|
} else {
|
||||||
@ -138,24 +140,28 @@ module.exports = class CommandManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const missing_permissions = cmd.permissions instanceof Array && !message.member.hasPermission(cmd.permissions);
|
const missing_permissions = cmd.permissions instanceof Array && !message.member.permissions.has(cmd.permissions);
|
||||||
if (missing_permissions) {
|
if (missing_permissions) {
|
||||||
const perms = cmd.permissions.map(p => `\`${p}\``).join(', ');
|
const perms = cmd.permissions.map(p => `\`${p}\``).join(', ');
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('missing_permissions.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('missing_permissions.description', perms))
|
.setTitle(i18n('missing_permissions.title'))
|
||||||
);
|
.setDescription(i18n('missing_permissions.description', perms))
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.staff_only && await message.member.isStaff() === false) {
|
if (cmd.staff_only && await this.client.utils.isStaff(message.member) === false) {
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('staff_only.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('staff_only.description'))
|
.setTitle(i18n('staff_only.title'))
|
||||||
);
|
.setDescription(i18n('staff_only.description'))
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = raw_args;
|
let args = raw_args;
|
||||||
@ -165,12 +171,14 @@ module.exports = class CommandManager {
|
|||||||
args = parseArgs(cmd.args, { argv: argv(raw_args) });
|
args = parseArgs(cmd.args, { argv: argv(raw_args) });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const help_cmd = `${settings.command_prefix}${i18n('commands.help.name')} ${cmd_name}`;
|
const help_cmd = `${settings.command_prefix}${i18n('commands.help.name')} ${cmd_name}`;
|
||||||
return await message.channel.send(
|
return await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.error_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('cmd_usage.invalid_named_args.title'))
|
.setColor(settings.error_colour)
|
||||||
.setDescription(i18n('cmd_usage.invalid_named_args.description', error.message, help_cmd))
|
.setTitle(i18n('cmd_usage.invalid_named_args.title'))
|
||||||
);
|
.setDescription(i18n('cmd_usage.invalid_named_args.description', error.message, help_cmd))
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
for (const arg of cmd.args) {
|
for (const arg of cmd.args) {
|
||||||
if (arg.required && args[arg.name] === undefined) {
|
if (arg.required && args[arg.name] === undefined) {
|
||||||
@ -191,13 +199,15 @@ module.exports = class CommandManager {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.client.log.warn(`An error occurred whilst executing the ${cmd.name} command`);
|
this.client.log.warn(`An error occurred whilst executing the ${cmd.name} command`);
|
||||||
this.client.log.error(e);
|
this.client.log.error(e);
|
||||||
await message.channel.send(
|
await message.channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor('ORANGE')
|
new MessageEmbed()
|
||||||
.setTitle(i18n('command_execution_error.title'))
|
.setColor('ORANGE')
|
||||||
.setDescription(i18n('command_execution_error.description'))
|
.setTitle(i18n('command_execution_error.title'))
|
||||||
); // hopefully no user will ever see this message
|
.setDescription(i18n('command_execution_error.description'))
|
||||||
|
]
|
||||||
|
}); // hopefully no user will ever see this message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const { path } = require('../utils/fs');
|
|
||||||
|
|
||||||
module.exports = () => {
|
|
||||||
const files = fs.readdirSync(path('./src/structures'))
|
|
||||||
.filter(file => file.endsWith('.js'));
|
|
||||||
|
|
||||||
for (const file of files) require(`../structures/${file}`);
|
|
||||||
};
|
|
@ -2,7 +2,6 @@
|
|||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const TicketArchives = require('./archives');
|
const TicketArchives = require('./archives');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const { footer } = require('../../utils/discord');
|
|
||||||
|
|
||||||
/** Manages tickets */
|
/** Manages tickets */
|
||||||
module.exports = class TicketManager extends EventEmitter {
|
module.exports = class TicketManager extends EventEmitter {
|
||||||
@ -51,10 +50,10 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
parent: category_id,
|
parent: category_id,
|
||||||
reason: `${creator.user.tag} requested a new ticket channel`,
|
reason: `${creator.user.tag} requested a new ticket channel`,
|
||||||
topic: `${creator}${topic.length > 0 ? ` | ${topic}` : ''}`,
|
topic: `${creator}${topic.length > 0 ? ` | ${topic}` : ''}`,
|
||||||
type: 'text'
|
type: 'GUILD_TEXT'
|
||||||
});
|
});
|
||||||
|
|
||||||
t_channel.updateOverwrite(creator_id, {
|
t_channel.permissionOverwrites.edit(creator_id, {
|
||||||
ATTACH_FILES: true,
|
ATTACH_FILES: true,
|
||||||
READ_MESSAGE_HISTORY: true,
|
READ_MESSAGE_HISTORY: true,
|
||||||
SEND_MESSAGES: true,
|
SEND_MESSAGES: true,
|
||||||
@ -71,7 +70,7 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const settings = await guild.getSettings();
|
const settings = await this.client.utils.getSettings(guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
|
|
||||||
topic = t_row.topic
|
topic = t_row.topic
|
||||||
@ -85,11 +84,11 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
? '@here'
|
? '@here'
|
||||||
: `<@&${id}>`);
|
: `<@&${id}>`);
|
||||||
|
|
||||||
await t_channel.send(mentions.join(', '));
|
await t_channel.send({ content: mentions.join(', ') });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cat_row.image) {
|
if (cat_row.image) {
|
||||||
await t_channel.send(cat_row.image);
|
await t_channel.send({ content: cat_row.image });
|
||||||
}
|
}
|
||||||
|
|
||||||
const description = cat_row.opening_message
|
const description = cat_row.opening_message
|
||||||
@ -103,7 +102,10 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
|
|
||||||
if (topic) embed.addField(i18n('ticket.opening_message.fields.topic'), topic);
|
if (topic) embed.addField(i18n('ticket.opening_message.fields.topic'), topic);
|
||||||
|
|
||||||
const sent = await t_channel.send(creator.user.toString(), embed);
|
const sent = await t_channel.send({
|
||||||
|
content: creator.user.toString(),
|
||||||
|
embeds: [embed]
|
||||||
|
});
|
||||||
await sent.pin({ reason: 'Ticket opening message' });
|
await sent.pin({ reason: 'Ticket opening message' });
|
||||||
|
|
||||||
await t_row.update({ opening_message: sent.id });
|
await t_row.update({ opening_message: sent.id });
|
||||||
@ -128,17 +130,21 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat_row.require_topic && topic.length === 0) {
|
if (cat_row.require_topic && topic.length === 0) {
|
||||||
const collector_message = await t_channel.send(
|
const collector_message = await t_channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle('⚠️ ' + i18n('commands.new.request_topic.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('commands.new.request_topic.description'))
|
.setTitle('⚠️ ' + i18n('commands.new.request_topic.title'))
|
||||||
.setFooter(footer(settings.footer, i18n('collector_expires_in', 120)), guild.iconURL())
|
.setDescription(i18n('commands.new.request_topic.description'))
|
||||||
);
|
.setFooter(this.client.utils.footer(settings.footer, i18n('collector_expires_in', 120)), guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
const collector_filter = message => message.author.id === t_row.creator;
|
const filter = message => message.author.id === t_row.creator;
|
||||||
|
const collector = t_channel.createMessageCollector({
|
||||||
const collector = t_channel.createMessageCollector(collector_filter, { time: 120000 });
|
filter,
|
||||||
|
time: 120000
|
||||||
|
});
|
||||||
|
|
||||||
collector.on('collect', async message => {
|
collector.on('collect', async message => {
|
||||||
topic = message.content;
|
topic = message.content;
|
||||||
@ -161,22 +167,26 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
.delete()
|
.delete()
|
||||||
.catch(() => this.client.log.warn('Failed to delete topic collector message'));
|
.catch(() => this.client.log.warn('Failed to delete topic collector message'));
|
||||||
if (cat_row.opening_questions) {
|
if (cat_row.opening_questions) {
|
||||||
await t_channel.send(
|
await t_channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setDescription(i18n('ticket.questions', questions))
|
.setColor(settings.colour)
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(i18n('ticket.questions', questions))
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (cat_row.opening_questions) {
|
if (cat_row.opening_questions) {
|
||||||
await t_channel.send(
|
await t_channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setDescription(i18n('ticket.questions', questions))
|
.setColor(settings.colour)
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(i18n('ticket.questions', questions))
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@ -203,7 +213,7 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
this.emit('beforeClose', ticket_id);
|
this.emit('beforeClose', ticket_id);
|
||||||
|
|
||||||
const guild = this.client.guilds.cache.get(t_row.guild);
|
const guild = this.client.guilds.cache.get(t_row.guild);
|
||||||
const settings = await guild.getSettings();
|
const settings = await this.client.utils.getSettings(guild);
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||||
const channel = await this.client.channels.fetch(t_row.id);
|
const channel = await this.client.channels.fetch(t_row.id);
|
||||||
|
|
||||||
@ -224,14 +234,16 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
const description = reason
|
const description = reason
|
||||||
? i18n('ticket.closed_by_member_with_reason.description', closer.user.toString(), reason)
|
? i18n('ticket.closed_by_member_with_reason.description', closer.user.toString(), reason)
|
||||||
: i18n('ticket.closed_by_member.description', closer.user.toString());
|
: i18n('ticket.closed_by_member.description', closer.user.toString());
|
||||||
await channel.send(
|
await channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setAuthor(closer.user.username, closer.user.displayAvatarURL())
|
.setColor(settings.success_colour)
|
||||||
.setTitle(i18n('ticket.closed.title'))
|
.setAuthor(closer.user.username, closer.user.displayAvatarURL())
|
||||||
.setDescription(description)
|
.setTitle(i18n('ticket.closed.title'))
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(description)
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await channel.delete(`Ticket channel closed by ${closer.user.tag}${reason ? `: "${reason}"` : ''}`);
|
await channel.delete(`Ticket channel closed by ${closer.user.tag}${reason ? `: "${reason}"` : ''}`);
|
||||||
@ -242,13 +254,15 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
const description = reason
|
const description = reason
|
||||||
? i18n('ticket.closed_with_reason.description')
|
? i18n('ticket.closed_with_reason.description')
|
||||||
: i18n('ticket.closed.description');
|
: i18n('ticket.closed.description');
|
||||||
await channel.send(
|
await channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('ticket.closed.title'))
|
.setColor(settings.success_colour)
|
||||||
.setDescription(description)
|
.setTitle(i18n('ticket.closed.title'))
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(description)
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await channel.delete(`Ticket channel closed${reason ? `: "${reason}"` : ''}`);
|
await channel.delete(`Ticket channel closed${reason ? `: "${reason}"` : ''}`);
|
||||||
@ -272,20 +286,25 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (survey) {
|
if (survey) {
|
||||||
const r_collector_message = await channel.send(
|
const r_collector_message = await channel.send({
|
||||||
creator.toString(),
|
content: creator.toString(),
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('ticket.survey.start.title'))
|
.setColor(settings.colour)
|
||||||
.setDescription(i18n('ticket.survey.start.description', creator.toString(), survey.questions.length))
|
.setTitle(i18n('ticket.survey.start.title'))
|
||||||
.setFooter(i18n('collector_expires_in', 60))
|
.setDescription(i18n('ticket.survey.start.description', creator.toString(), survey.questions.length))
|
||||||
);
|
.setFooter(i18n('collector_expires_in', 60))
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
await r_collector_message.react('✅');
|
await r_collector_message.react('✅');
|
||||||
|
|
||||||
const collector_filter = (reaction, user) => user.id === creator.user.id && reaction.emoji.name === '✅';
|
const filter = (reaction, user) => user.id === creator.user.id && reaction.emoji.name === '✅';
|
||||||
|
|
||||||
const r_collector = r_collector_message.createReactionCollector(collector_filter, { time: 60000 });
|
const r_collector = r_collector_message.createReactionCollector({
|
||||||
|
filter,
|
||||||
|
time: 60000
|
||||||
|
});
|
||||||
|
|
||||||
r_collector.on('collect', async () => {
|
r_collector.on('collect', async () => {
|
||||||
r_collector.stop();
|
r_collector.stop();
|
||||||
@ -293,17 +312,20 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
let answers = [];
|
let answers = [];
|
||||||
let number = 1;
|
let number = 1;
|
||||||
for (const question of survey.questions) {
|
for (const question of survey.questions) {
|
||||||
await channel.send(
|
await channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.colour)
|
new MessageEmbed()
|
||||||
.setTitle(`${number++}/${survey.questions.length}`)
|
.setColor(settings.colour)
|
||||||
.setDescription(question)
|
.setTitle(`${number++}/${survey.questions.length}`)
|
||||||
.setFooter(i18n('collector_expires_in', 60))
|
.setDescription(question)
|
||||||
);
|
.setFooter(i18n('collector_expires_in', 60))
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const collected = await channel.awaitMessages(filter, {
|
const collected = await channel.awaitMessages({
|
||||||
errors: ['time'],
|
errors: ['time'],
|
||||||
|
filter,
|
||||||
max: 1,
|
max: 1,
|
||||||
time: 60000
|
time: 60000
|
||||||
});
|
});
|
||||||
@ -313,13 +335,15 @@ module.exports = class TicketManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await channel.send(
|
await channel.send({
|
||||||
new MessageEmbed()
|
embeds: [
|
||||||
.setColor(settings.success_colour)
|
new MessageEmbed()
|
||||||
.setTitle(i18n('ticket.survey.complete.title'))
|
.setColor(settings.success_colour)
|
||||||
.setDescription(i18n('ticket.survey.complete.description'))
|
.setTitle(i18n('ticket.survey.complete.title'))
|
||||||
.setFooter(settings.footer, guild.iconURL())
|
.setDescription(i18n('ticket.survey.complete.description'))
|
||||||
);
|
.setFooter(settings.footer, guild.iconURL())
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
answers = answers.map(a => this.client.cryptr.encrypt(a));
|
answers = answers.map(a => this.client.cryptr.encrypt(a));
|
||||||
await this.client.db.models.SurveyResponse.create({
|
await this.client.db.models.SurveyResponse.create({
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
const { Structures } = require('discord.js');
|
|
||||||
|
|
||||||
Structures.extend('Guild', Guild => class extends Guild {
|
|
||||||
constructor(client, data) {
|
|
||||||
super(client, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteSettings() {
|
|
||||||
const row = await this.settings;
|
|
||||||
return await row.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
async getSettings() {
|
|
||||||
const data = { id: this.id };
|
|
||||||
const [settings] = await this.client.db.models.Guild.findOrCreate({
|
|
||||||
defaults: data,
|
|
||||||
where: data
|
|
||||||
});
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,14 +0,0 @@
|
|||||||
const { Structures } = require('discord.js');
|
|
||||||
|
|
||||||
Structures.extend('GuildMember', GuildMember => class extends GuildMember {
|
|
||||||
constructor(client, data, guild) {
|
|
||||||
super(client, data, guild);
|
|
||||||
}
|
|
||||||
|
|
||||||
async isStaff() {
|
|
||||||
const guild_categories = await this.client.db.models.Category.findAll({ where: { guild: this.guild.id } });
|
|
||||||
|
|
||||||
return guild_categories.some(cat => cat.roles.some(r => this.roles.cache.has(r)));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
@ -1,23 +1,66 @@
|
|||||||
const config = require('../../user/config');
|
|
||||||
|
|
||||||
|
const {
|
||||||
|
Guild, // eslint-disable-line no-unused-vars
|
||||||
|
GuildMember // eslint-disable-line no-unused-vars
|
||||||
|
} = require('discord.js');
|
||||||
|
const config = require('../../user/config');
|
||||||
let current_presence = -1;
|
let current_presence = -1;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = class DiscordUtils {
|
||||||
|
constructor(client) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Generate embed footer text
|
||||||
* @param {string} text
|
* @param {string} text
|
||||||
* @param {string} [additional]
|
* @param {string} [additional]
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
footer: (text, additional) => {
|
footer(text, additional) {
|
||||||
if (text && additional) return `${text} | ${additional}`;
|
if (text && additional) return `${text} | ${additional}`;
|
||||||
else return additional || text || '';
|
else return additional || text || '';
|
||||||
},
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a guild member is staff
|
||||||
|
* @param {GuildMember} member - the guild member
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
async isStaff(member) {
|
||||||
|
const guild_categories = await this.client.db.models.Category.findAll({ where: { guild: member.guild.id } });
|
||||||
|
return guild_categories.some(cat => cat.roles.some(r => member.roles.cache.has(r)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a guild's settings
|
||||||
|
* @param {Guild} guild - The Guild
|
||||||
|
* @returns {Promise<Model>}
|
||||||
|
*/
|
||||||
|
async getSettings(guild) {
|
||||||
|
const data = { id: guild.id };
|
||||||
|
const [settings] = await this.client.db.models.Guild.findOrCreate({
|
||||||
|
defaults: data,
|
||||||
|
where: data
|
||||||
|
});
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a guild's settings
|
||||||
|
* @param {Guild} guild - The Guild
|
||||||
|
* @returns {Promise<Number>}
|
||||||
|
*/
|
||||||
|
async deleteSettings(guild) {
|
||||||
|
const row = await this.getSettings(guild);
|
||||||
|
return await row.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select a presence from the config
|
* Select a presence from the config
|
||||||
* @returns {PresenceData}
|
* @returns {PresenceData}
|
||||||
*/
|
*/
|
||||||
selectPresence: () => {
|
static selectPresence() {
|
||||||
const length = config.presence.presences.length;
|
const length = config.presence.presences.length;
|
||||||
if (length === 0) return {};
|
if (length === 0) return {};
|
||||||
|
|
||||||
@ -42,11 +85,13 @@ module.exports = {
|
|||||||
} = config.presence.presences[num];
|
} = config.presence.presences[num];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activity: {
|
activities: [
|
||||||
name,
|
{
|
||||||
type,
|
name,
|
||||||
url
|
type,
|
||||||
},
|
url
|
||||||
|
}
|
||||||
|
],
|
||||||
status
|
status
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user