mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
progress
This commit is contained in:
parent
9016da2f73
commit
5e9e23bbf2
@ -2,7 +2,7 @@
|
||||
"name": "@eartharoid/discordtickets",
|
||||
"version": "3.0.0",
|
||||
"private": true,
|
||||
"description": "An open-source & self-hosted Discord bot for ticket management.",
|
||||
"description": "An open-source Discord bot for ticket management",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"start": "node src/",
|
||||
|
@ -28,14 +28,13 @@ module.exports = class NewCommand extends Command {
|
||||
}
|
||||
|
||||
async execute({ guild, member, channel, args}, interaction) {
|
||||
console.log(args);
|
||||
// console.log(channel.name);
|
||||
// console.log(member.user.tag);
|
||||
// console.log(guild.name);
|
||||
|
||||
const i18n = this.client.i18n.get(/* GET GUILD LOCALE FROM SETTINGS */);
|
||||
let settings = await guild.settings;
|
||||
const i18n = this.client.i18n.get(settings.locale);
|
||||
|
||||
return new MessageEmbed()
|
||||
.setTitle(i18n('bot.version', require('../../package.json').version));
|
||||
.setColor(settings.colour)
|
||||
.setTitle(i18n('bot.version', require('../../package.json').version))
|
||||
.secret = true;
|
||||
}
|
||||
};
|
@ -66,6 +66,10 @@ module.exports = async (log) => {
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
colour: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: config.defaults.colour
|
||||
},
|
||||
locale: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: config.defaults.locale
|
||||
|
11
src/index.js
11
src/index.js
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @name @eartharoid/discordtickets
|
||||
* @description An open-source & self-hosted Discord bot for ticket management.
|
||||
* @description An open-source Discord bot for ticket management
|
||||
* @copyright 2021 Isaac Saunders
|
||||
* @license GNU-GPLv3
|
||||
*/
|
||||
@ -52,8 +52,6 @@ if (!checkFile('./.env', './example.env')) {
|
||||
|
||||
checkFile('./user/config.js', './user/example.config.js');
|
||||
|
||||
|
||||
|
||||
require('dotenv').config({
|
||||
path: path('./.env')
|
||||
});
|
||||
@ -67,6 +65,7 @@ const log = new Logger({
|
||||
name: 'DiscordTickets by eartharoid',
|
||||
debug: config.debug,
|
||||
logToFile: config.logs.enabled,
|
||||
directory: path('./logs/'),
|
||||
keepFor: config.logs.keep_for,
|
||||
custom: {
|
||||
commands: {
|
||||
@ -76,6 +75,10 @@ const log = new Logger({
|
||||
plugins: {
|
||||
title: 'info',
|
||||
prefix: 'plugins'
|
||||
},
|
||||
tickets: {
|
||||
title: 'info',
|
||||
prefix: 'tickets'
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -85,6 +88,8 @@ const I18n = require('@eartharoid/i18n');
|
||||
const { CommandManager } = require('./modules/commands');
|
||||
const { PluginManager } = require('./modules/plugins');
|
||||
|
||||
require('./modules/structures')(); // load extended structures before creating the client
|
||||
|
||||
const {
|
||||
Client,
|
||||
Intents
|
||||
|
7
src/listeners/guildCreate.js
Normal file
7
src/listeners/guildCreate.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
event: 'guildCreate',
|
||||
execute: async (client, guild) => {
|
||||
client.log.console(`Added to ${guild.name}`);
|
||||
await guild.createSettings();
|
||||
}
|
||||
};
|
7
src/listeners/guildDelete.js
Normal file
7
src/listeners/guildDelete.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
event: 'guildDelete',
|
||||
execute: async (client, guild) => {
|
||||
client.log.console(`Removed from ${guild.name}`);
|
||||
await guild.deleteSettings();
|
||||
}
|
||||
};
|
@ -8,7 +8,7 @@ module.exports = {
|
||||
client.log.debug('Received interaction ping, responding with pong');
|
||||
await client.api.interactions(interaction.id, interaction.token).callback.post({
|
||||
data: {
|
||||
type: 1,
|
||||
type: 1, // PONG
|
||||
}
|
||||
});
|
||||
break;
|
||||
@ -17,7 +17,5 @@ module.exports = {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
@ -1,5 +1,13 @@
|
||||
{
|
||||
"admin_only": "❌ You must be an administrator to use this command.",
|
||||
"bot": {
|
||||
"version": "DiscordTickets v%s by eartharoid"
|
||||
}
|
||||
},
|
||||
"cmd": {
|
||||
"new": {
|
||||
|
||||
}
|
||||
},
|
||||
"no_perm": "❌ You do not have the permissions required to use this command:\n%s",
|
||||
"support_only": "❌ You must be a member of staff to use this command."
|
||||
}
|
@ -177,7 +177,9 @@ module.exports = class Command {
|
||||
data: {
|
||||
type: 4,
|
||||
flags: flags(secret),
|
||||
content
|
||||
data: {
|
||||
content
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ module.exports = class CommandManager {
|
||||
/**
|
||||
* Execute a command
|
||||
* @param {string} cmd_name - Name of the command
|
||||
* @param {interaction} interaction - Command interaction
|
||||
* @param {Interaction} interaction - Command interaction
|
||||
*/
|
||||
async execute(cmd_name, interaction) {
|
||||
if (!this.commands.has(cmd_name))
|
||||
@ -157,6 +157,11 @@ module.exports = class CommandManager {
|
||||
|
||||
const cmd = this.commands.get(cmd_name);
|
||||
|
||||
let settings = await data.guild.settings;
|
||||
if (!settings)
|
||||
settings = await data.guild.createSettings();
|
||||
const i18n = this.client.i18n.get(settings.locale);
|
||||
|
||||
// if (cmd.staff_only) {
|
||||
// return await cmd.sendResponse(interaction, msg, true);
|
||||
// }
|
||||
@ -165,7 +170,7 @@ module.exports = class CommandManager {
|
||||
&& !data.member.hasPermission(cmd.permissions);
|
||||
if (no_perm) {
|
||||
let perms = cmd.permissions.map(p => `\`${p}\``).join(', ');
|
||||
let msg = `❌ You do not have the permissions required to use this command:\n${perms}`;
|
||||
let msg = i18n('no_perm', perms);
|
||||
return await cmd.sendResponse(interaction, msg, true);
|
||||
}
|
||||
|
||||
|
10
src/modules/structures.js
Normal file
10
src/modules/structures.js
Normal file
@ -0,0 +1,10 @@
|
||||
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}`);
|
||||
};
|
@ -6,8 +6,19 @@ Structures.extend('Guild', Guild => {
|
||||
super(client, data);
|
||||
}
|
||||
|
||||
createSettings() {
|
||||
return this.client.db.models.Guild.create({
|
||||
id: this.id
|
||||
});
|
||||
}
|
||||
|
||||
async deleteSettings() {
|
||||
let row = await this.settings;
|
||||
return await row.destroy();
|
||||
}
|
||||
|
||||
get settings() {
|
||||
return this.client.db.Guild.findOne({
|
||||
return this.client.db.models.Guild.findOne({
|
||||
where: {
|
||||
id: this.id
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user