mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Fix settings
This commit is contained in:
parent
3918bc136c
commit
777719d1b3
@ -34,7 +34,7 @@ module.exports = class AddCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const ticket = message.mentions.channels.first() ?? message.channel;
|
||||
|
@ -31,7 +31,7 @@ module.exports = class BlacklistCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const member = message.mentions.members.first();
|
||||
|
@ -59,7 +59,7 @@ module.exports = class CloseCommand extends Command {
|
||||
const arg_reason = this.args[1].name;
|
||||
const arg_time = this.args[2].name;
|
||||
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
if (args[arg_time]) {
|
||||
|
@ -31,7 +31,7 @@ module.exports = class HelpCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const cmd = this.manager.commands.find(command => command.aliases.includes(args.toLowerCase()));
|
||||
|
@ -35,7 +35,7 @@ module.exports = class NewCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const editOrSend = async (msg, content) => {
|
||||
|
@ -69,7 +69,7 @@ module.exports = class PanelCommand extends Command {
|
||||
const arg_emoji = this.args[2].name;
|
||||
const arg_categories = this.args[3].name;
|
||||
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
if (!args[arg_emoji])
|
||||
|
@ -34,7 +34,7 @@ module.exports = class RemoveCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const ticket = message.mentions.channels.first() ?? message.channel;
|
||||
|
@ -29,7 +29,7 @@ module.exports = class SettingsCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const attachments = [...message.attachments.values()];
|
||||
|
@ -27,7 +27,7 @@ module.exports = class StatsCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const messages = await this.client.db.models.Message.findAndCountAll();
|
||||
|
@ -34,7 +34,7 @@ module.exports = class SurveyCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const survey = await this.client.db.models.Survey.findOne({
|
||||
|
@ -35,7 +35,7 @@ module.exports = class TagCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const t_row = await this.client.db.models.Ticket.findOne({
|
||||
|
@ -28,7 +28,7 @@ module.exports = class TopicCommand extends Command {
|
||||
* @returns {Promise<void|any>}
|
||||
*/
|
||||
async execute(message, args) {
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const t_row = await this.client.db.models.Ticket.findOne({
|
||||
|
@ -13,7 +13,7 @@ module.exports = class MessageEventListener extends EventListener {
|
||||
async execute(message) {
|
||||
if (!message.guild) return;
|
||||
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const t_row = await this.client.db.models.Ticket.findOne({
|
||||
|
@ -10,7 +10,7 @@ module.exports = class MessageDeleteEventListener extends EventListener {
|
||||
async execute(message) {
|
||||
if (!message.guild) return;
|
||||
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
|
||||
if (settings.log_messages && !message.system) this.client.tickets.archives.deleteMessage(message); // mark the message as deleted in the database (if it exists)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ module.exports = class MessageReactionAddEventListener extends EventListener {
|
||||
const guild = r.message.guild;
|
||||
if (!guild) return;
|
||||
|
||||
const settings = await guild.settings;
|
||||
const settings = await guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const channel = r.message.channel;
|
||||
|
@ -32,7 +32,7 @@ module.exports = class MessageReactionRemoveEventListener extends EventListener
|
||||
const guild = r.message.guild;
|
||||
if (!guild) return;
|
||||
|
||||
const settings = await guild.settings;
|
||||
const settings = await guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
const channel = r.message.channel;
|
||||
|
@ -18,7 +18,7 @@ module.exports = class MessageUpdateEventListener extends EventListener {
|
||||
|
||||
if (!newm.guild) return;
|
||||
|
||||
const settings = await newm.guild.settings;
|
||||
const settings = await newm.guild.getSettings();
|
||||
|
||||
if (settings.log_messages && !newm.system) this.client.tickets.archives.updateMessage(newm); // update the message in the database
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ module.exports = class Command {
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async sendUsage(channel, alias) {
|
||||
const settings = await channel.guild.settings;
|
||||
const settings = await channel.guild.getSettings();
|
||||
if (!alias) alias = this.name;
|
||||
|
||||
const prefix = settings.command_prefix;
|
||||
|
@ -69,7 +69,7 @@ module.exports = class CommandManager {
|
||||
async handle(message) {
|
||||
if (message.author.bot) return; // ignore self and other bots
|
||||
|
||||
const settings = await message.guild.settings;
|
||||
const settings = await message.guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
let is_blacklisted = false;
|
||||
|
@ -80,7 +80,7 @@ module.exports = class TicketManager extends EventEmitter {
|
||||
});
|
||||
|
||||
(async () => {
|
||||
const settings = await guild.settings;
|
||||
const settings = await guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
topic = t_row.topic
|
||||
@ -218,7 +218,7 @@ module.exports = class TicketManager extends EventEmitter {
|
||||
this.emit('beforeClose', ticket_id);
|
||||
|
||||
const guild = this.client.guilds.cache.get(t_row.guild);
|
||||
const settings = await guild.settings;
|
||||
const settings = await guild.getSettings();
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
const channel = await this.client.channels.fetch(t_row.id);
|
||||
|
||||
|
@ -11,14 +11,15 @@ Structures.extend('Guild', Guild => {
|
||||
return await row.destroy();
|
||||
}
|
||||
|
||||
get settings() {
|
||||
async getSettings() {
|
||||
const data = {
|
||||
id: this.id
|
||||
};
|
||||
return this.client.db.models.Guild.findOrCreate({
|
||||
const [settings] = await this.client.db.models.Guild.findOrCreate({
|
||||
defaults: data,
|
||||
where: data
|
||||
});
|
||||
return settings;
|
||||
}
|
||||
};
|
||||
});
|
Loading…
Reference in New Issue
Block a user