put the blacklist in mysql
This commit is contained in:
parent
68a45d5de6
commit
c6068c924c
9 changed files with 134 additions and 11 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
30
migrations/20191006180114-create-twitter-blacklist.js
Normal file
30
migrations/20191006180114-create-twitter-blacklist.js
Normal file
|
@ -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');
|
||||
}
|
||||
};
|
27
migrations/20191006181945-create-guild-blacklist.js
Normal file
27
migrations/20191006181945-create-guild-blacklist.js
Normal file
|
@ -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');
|
||||
}
|
||||
};
|
27
migrations/20191006181953-create-user-blacklist.js
Normal file
27
migrations/20191006181953-create-user-blacklist.js
Normal file
|
@ -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');
|
||||
}
|
||||
};
|
10
models/guildblacklist.js
Normal file
10
models/guildblacklist.js
Normal file
|
@ -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;
|
||||
};
|
11
models/twitterblacklist.js
Normal file
11
models/twitterblacklist.js
Normal file
|
@ -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;
|
||||
};
|
10
models/userblacklist.js
Normal file
10
models/userblacklist.js
Normal file
|
@ -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;
|
||||
};
|
Loading…
Reference in a new issue