Add helper function for bot settings
and fix registration check always returning true
This commit is contained in:
@@ -7,8 +7,11 @@ const { UserUtils } = require("../util");
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: "interactionCreate",
|
name: "interactionCreate",
|
||||||
async execute (interaction) {
|
async execute (interaction) {
|
||||||
if (!UserUtils.registrationCheck(interaction)) return;
|
let isRegistered = await UserUtils.registrationCheck(interaction);
|
||||||
|
if (!isRegistered) return;
|
||||||
|
console.log("User is registered");
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
|
console.log("Interaction is a command");
|
||||||
|
|
||||||
const guild = await interaction.guild;
|
const guild = await interaction.guild;
|
||||||
//check if guild exists in database
|
//check if guild exists in database
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
async up (queryInterface, Sequelize) {
|
async up (queryInterface, Sequelize) {
|
||||||
await queryInterface.createTable('Bot', {
|
await queryInterface.createTable('Bots', {
|
||||||
id: {
|
id: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
@@ -31,6 +31,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async down (queryInterface, Sequelize) {
|
async down (queryInterface, Sequelize) {
|
||||||
await queryInterface.dropTable('Bot');
|
await queryInterface.dropTable('Bots');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
}
|
}
|
||||||
Bot.init({
|
Bot.init({
|
||||||
maintenance: DataTypes.BOOLEAN,
|
maintenance: DataTypes.BOOLEAN,
|
||||||
adminIDs: DataTypes.STRING
|
adminIDs: DataTypes.STRING,
|
||||||
|
pullTimeout: DataTypes.INTEGER,
|
||||||
|
dropTimeout: DataTypes.INTEGER
|
||||||
}, {
|
}, {
|
||||||
sequelize,
|
sequelize,
|
||||||
modelName: 'Guild',
|
modelName: 'Bot',
|
||||||
});
|
});
|
||||||
return Bot;
|
return Bot;
|
||||||
};
|
};
|
||||||
17
seeders/20220819111700-core-bot-config.js
Normal file
17
seeders/20220819111700-core-bot-config.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
async up (queryInterface, Sequelize) {
|
||||||
|
await queryInterface.bulkInsert('Bots', [{
|
||||||
|
id: 1,
|
||||||
|
maintenance: 0,
|
||||||
|
adminIDs: '["222457277708369928"]',
|
||||||
|
pullTimeout: 300000,
|
||||||
|
dropTimeout: 900000
|
||||||
|
}]);
|
||||||
|
},
|
||||||
|
|
||||||
|
async down (queryInterface, Sequelize) {
|
||||||
|
await queryInterface.bulkDelete('Bots', null, {});
|
||||||
|
}
|
||||||
|
};
|
||||||
9
util/general.js
Normal file
9
util/general.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const { Bot } = require("../models");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "GeneralUtils",
|
||||||
|
getBotProperty: async function(property) {
|
||||||
|
let bot = await Bot.findOne();
|
||||||
|
return property ? bot[property] : bot;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user