diff --git a/commands/general/tweet.js b/commands/general/tweet.js index 9e56914..dfe4d73 100644 --- a/commands/general/tweet.js +++ b/commands/general/tweet.js @@ -4,8 +4,8 @@ const rand = require('../../rand.js'); const { MessageEmbed } = require('discord.js'); //const Filter = require('bad-words'); //let filter = new Filter(); +const TwitterBlacklist = require('../../models').TwitterBlacklist; const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret, twiChannel } = require('../../config.json'); -const reload = require('auto-reload'); class tweetCommand extends Command { constructor() { @@ -32,24 +32,25 @@ class tweetCommand extends Command { async exec(message, args) { /* + // Censor words let censor = reload('../../json/censor.json'); let uncensor = reload('../../json/uncensor.json'); filter.addWords(...censor); filter.removeWords(...uncensor); */ + // see if user is not banned + const blacklist = await TwitterBlacklist.findOne({where: {userID:message.author.id}}); + if (blacklist) { + return message.channel.send(`You have been blacklisted for the following reasons: \`\`${blacklist.get('reason')}\`\` be less naughty less time.`); + } + // Don't let account new account use this command to prevent spam let date = new Date(); if (message.author.createdAt > date.setDate(date.getDate() - 7)) { return message.channel.send('Your account is too new to be able to use this command!'); } - const blacklist = reload('../../json/twiBlacklist.json'); - - if (blacklist.includes(message.author.id)) { - return message.channel.send('You have been blacklisted from this command... be less naughty next time.'); - } - // remove zero width space let text = args.text.replace('​', ''); if (!text) diff --git a/event/inhibitors/blacklist.js b/event/inhibitors/blacklist.js index 803487f..a83f984 100644 --- a/event/inhibitors/blacklist.js +++ b/event/inhibitors/blacklist.js @@ -1,4 +1,5 @@ const { Inhibitor } = require('discord-akairo'); +const userBlacklist = require('../../models').userBlacklist; class BlacklistInhibitor extends Inhibitor { constructor() { @@ -8,8 +9,11 @@ class BlacklistInhibitor extends Inhibitor { } async exec(message) { - const blacklist = ['501856229123948545', '497730155691638784', '29476879240658944', '530399670728392737', '595102888796356628', '342039250302140418', '319180626928336896', '476412819278004236']; - return blacklist.includes(message.author.id); + //const blacklist = ['501856229123948545', '497730155691638784', '29476879240658944', '530399670728392737', '595102888796356628', '342039250302140418', '319180626928336896', '476412819278004236']; + + const blacklist = await userBlacklist.findOne({where: {userID:message.author.id}}); + + if (blacklist) return true; } } diff --git a/event/inhibitors/serverblacklist.js b/event/inhibitors/serverblacklist.js index 8a8a58d..e71d5d9 100644 --- a/event/inhibitors/serverblacklist.js +++ b/event/inhibitors/serverblacklist.js @@ -1,4 +1,5 @@ const { Inhibitor } = require('discord-akairo'); +const guildBlacklist = require('../../models').guildBlacklist; class serverblacklistInhibitor extends Inhibitor { constructor() { @@ -8,8 +9,10 @@ class serverblacklistInhibitor extends Inhibitor { } async exec(message) { - const blacklist = ['595100178915262464', '630127127450091521', '630128971576770580']; - return blacklist.includes(message.guild.id); + const blacklist = await guildBlacklist.findOne({where: {guildID:message.guild.id}}); + + if (blacklist) return true; + } } diff --git a/migrations/20191006180114-create-twitter-blacklist.js b/migrations/20191006180114-create-twitter-blacklist.js new file mode 100644 index 0000000..72289cb --- /dev/null +++ b/migrations/20191006180114-create-twitter-blacklist.js @@ -0,0 +1,30 @@ +'use strict'; +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('TwitterBlacklists', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + userID: { + type: Sequelize.BIGINT + }, + reason: { + type: Sequelize.STRING + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('TwitterBlacklists'); + } +}; \ No newline at end of file diff --git a/migrations/20191006181945-create-guild-blacklist.js b/migrations/20191006181945-create-guild-blacklist.js new file mode 100644 index 0000000..d50830b --- /dev/null +++ b/migrations/20191006181945-create-guild-blacklist.js @@ -0,0 +1,27 @@ +'use strict'; +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('guildBlacklists', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + guildID: { + type: Sequelize.BIGINT + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('guildBlacklists'); + } +}; \ No newline at end of file diff --git a/migrations/20191006181953-create-user-blacklist.js b/migrations/20191006181953-create-user-blacklist.js new file mode 100644 index 0000000..5089d1b --- /dev/null +++ b/migrations/20191006181953-create-user-blacklist.js @@ -0,0 +1,27 @@ +'use strict'; +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.createTable('userBlacklists', { + id: { + allowNull: false, + autoIncrement: true, + primaryKey: true, + type: Sequelize.INTEGER + }, + userID: { + type: Sequelize.BIGINT + }, + createdAt: { + allowNull: false, + type: Sequelize.DATE + }, + updatedAt: { + allowNull: false, + type: Sequelize.DATE + } + }); + }, + down: (queryInterface, Sequelize) => { + return queryInterface.dropTable('userBlacklists'); + } +}; \ No newline at end of file diff --git a/models/guildblacklist.js b/models/guildblacklist.js new file mode 100644 index 0000000..3f79b43 --- /dev/null +++ b/models/guildblacklist.js @@ -0,0 +1,10 @@ +'use strict'; +module.exports = (sequelize, DataTypes) => { + const guildBlacklist = sequelize.define('guildBlacklist', { + guildID: DataTypes.BIGINT + }, {}); + guildBlacklist.associate = function(models) { + // associations can be defined here + }; + return guildBlacklist; +}; \ No newline at end of file diff --git a/models/twitterblacklist.js b/models/twitterblacklist.js new file mode 100644 index 0000000..105aeb5 --- /dev/null +++ b/models/twitterblacklist.js @@ -0,0 +1,11 @@ +'use strict'; +module.exports = (sequelize, DataTypes) => { + const TwitterBlacklist = sequelize.define('TwitterBlacklist', { + userID: DataTypes.BIGINT, + reason: DataTypes.STRING + }, {}); + TwitterBlacklist.associate = function(models) { + // associations can be defined here + }; + return TwitterBlacklist; +}; \ No newline at end of file diff --git a/models/userblacklist.js b/models/userblacklist.js new file mode 100644 index 0000000..6255d9e --- /dev/null +++ b/models/userblacklist.js @@ -0,0 +1,10 @@ +'use strict'; +module.exports = (sequelize, DataTypes) => { + const userBlacklist = sequelize.define('userBlacklist', { + userID: DataTypes.BIGINT + }, {}); + userBlacklist.associate = function(models) { + // associations can be defined here + }; + return userBlacklist; +}; \ No newline at end of file