forked from Supositware/Haha-Yes
Merge branch 'master' of https://gitlab.com/loicbersier/discordbot
commit
af3762b90d
@ -0,0 +1,45 @@
|
||||
const { Command } = require('discord-akairo');
|
||||
const quotationStat = require('../../models').quotationStat;
|
||||
|
||||
class quotationCommand extends Command {
|
||||
constructor() {
|
||||
super('quotation', {
|
||||
aliases: ['quotation'],
|
||||
category: 'admin',
|
||||
args: [
|
||||
{
|
||||
id: 'stat',
|
||||
type: 'string',
|
||||
prompt: {
|
||||
start: 'Do you want to **enable** or **disable** quotation?',
|
||||
}
|
||||
}
|
||||
],
|
||||
clientPermissions: ['SEND_MESSAGES'],
|
||||
userPermissions: ['MANAGE_MESSAGES'],
|
||||
channelRestriction: 'guild',
|
||||
description: {
|
||||
content: 'enable/disable quotation',
|
||||
usage: '[enable/disable]',
|
||||
examples: ['enable']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
if (args.stat.toLowerCase() == 'enable' || args.stat.toLowerCase() == 'disable') {
|
||||
const quotationstat = await quotationStat.findOne({where: {serverID: message.guild.id}});
|
||||
|
||||
if (!quotationstat) {
|
||||
const body = {serverID: message.guild.id, stat: args.stat};
|
||||
quotationStat.create(body);
|
||||
return message.channel.send(`Quotation has been ${args.stat}d`);
|
||||
} else {
|
||||
const body = {serverID: message.guild.id, stat: args.stat};
|
||||
quotationStat.update(body, {where: {serverID: message.guild.id}});
|
||||
return message.channel.send(`Quotation has been ${args.stat}d`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = quotationCommand;
|
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('quotationStats', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
serverID: {
|
||||
type: Sequelize.BIGINT
|
||||
},
|
||||
stat: {
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('quotationStats');
|
||||
}
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const quotationStat = sequelize.define('quotationStat', {
|
||||
serverID: DataTypes.BIGINT,
|
||||
stat: DataTypes.STRING
|
||||
}, {});
|
||||
quotationStat.associate = function(models) {
|
||||
// associations can be defined here
|
||||
};
|
||||
return quotationStat;
|
||||
};
|
Loading…
Reference in New Issue