Compare commits
4 commits
8863fa6050
...
02a858bf48
Author | SHA1 | Date | |
---|---|---|---|
02a858bf48 | |||
31da6d966a | |||
d835982972 | |||
219ecfaab5 |
19 changed files with 289 additions and 22 deletions
52
commands/admin/commandblockuser.js
Normal file
52
commands/admin/commandblockuser.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
const { Command } = require('discord-akairo');
|
||||||
|
const commandblockuser = require('../../models').commandblockuser;
|
||||||
|
|
||||||
|
class commandblockuserCommand extends Command {
|
||||||
|
constructor() {
|
||||||
|
super('commandblockuser', {
|
||||||
|
aliases: ['commandblockuser', 'userblockcommand'],
|
||||||
|
category: 'admin',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
id: 'command',
|
||||||
|
type: 'command',
|
||||||
|
prompt: {
|
||||||
|
start: 'What command do you want to block?',
|
||||||
|
retry: 'Not a valid command, please try again'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'user',
|
||||||
|
type: 'user',
|
||||||
|
prompt: {
|
||||||
|
start: 'Which user you want to block?'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
clientPermissions: ['SEND_MESSAGES'],
|
||||||
|
userPermissions: ['ADMINISTRATOR'],
|
||||||
|
channel: 'guild',
|
||||||
|
description: {
|
||||||
|
content: 'Block a command from a user. Execute that command again to unblock a command',
|
||||||
|
usage: '[command name] [@user]',
|
||||||
|
examples: ['owned @supositware']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async exec(message, args) {
|
||||||
|
if (args.command.id == 'commandblockuser') return message.channel.send('Whoa there, i can\'t let you block this command or else how would you unblock it?');
|
||||||
|
|
||||||
|
const blocked = await commandblockuser.findOne({where: {serverID: message.guild.id, userID: args.user.id, command: args.command.id}});
|
||||||
|
|
||||||
|
if (!blocked) {
|
||||||
|
const body = {serverID: message.guild.id, userID: args.user.id, command: args.command.id};
|
||||||
|
commandblockuser.create(body);
|
||||||
|
return message.channel.send(`Blocked command ${args.command.id}`);
|
||||||
|
} else {
|
||||||
|
commandblockuser.destroy({where: {serverID: message.guild.id, userID: args.user.id, command: args.command.id}});
|
||||||
|
return message.channel.send(`The command ${args.command.id} has been unblocked`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = commandblockuserCommand;
|
|
@ -8,7 +8,7 @@ const downloader = require('../../utils/download');
|
||||||
const md5File = require('md5-file');
|
const md5File = require('md5-file');
|
||||||
const ytpHash = require('../../models').ytpHash;
|
const ytpHash = require('../../models').ytpHash;
|
||||||
const { ytpChannel } = require('../../config.json');
|
const { ytpChannel } = require('../../config.json');
|
||||||
const ytpblacklist = require('../../models').ytpblacklist;
|
//const ytpblacklist = require('../../models').ytpblacklist;
|
||||||
|
|
||||||
const MAX_CLIPS = 20;
|
const MAX_CLIPS = 20;
|
||||||
|
|
||||||
|
@ -165,11 +165,13 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.add) {
|
if (args.add) {
|
||||||
|
/*
|
||||||
const blacklist = await ytpblacklist.findOne({where: {userID:message.author.id}});
|
const blacklist = await ytpblacklist.findOne({where: {userID:message.author.id}});
|
||||||
|
|
||||||
if (blacklist) {
|
if (blacklist) {
|
||||||
return message.channel.send(`You have been blacklisted for the following reasons: \`${blacklist.get('reason')}\` be less naughty next time.`);
|
return message.channel.send(`You have been blacklisted for the following reasons: \`${blacklist.get('reason')}\` be less naughty next time.`);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (args.proxy && !args.proxyAuto) { // args.proxyAuto is only provided when the command is run after a error 429
|
if (args.proxy && !args.proxyAuto) { // args.proxyAuto is only provided when the command is run after a error 429
|
||||||
args.proxy = args.proxy -1;
|
args.proxy = args.proxy -1;
|
||||||
|
|
|
@ -4,7 +4,8 @@ const fetch = require('node-fetch');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const rand = require('../../rand.js');
|
const rand = require('../../rand.js');
|
||||||
const TwitterBlacklist = require('../../models').TwitterBlacklist;
|
//const TwitterBlacklist = require('../../models').TwitterBlacklist;
|
||||||
|
const Blacklists = require('../../models').Blacklists;
|
||||||
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret, twiChannel } = require('../../config.json');
|
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret, twiChannel } = require('../../config.json');
|
||||||
const wordToCensor = require('../../json/censor.json');
|
const wordToCensor = require('../../json/censor.json');
|
||||||
|
|
||||||
|
@ -37,11 +38,13 @@ class tweetCommand extends Command {
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
// see if user is not banned
|
// see if user is not banned
|
||||||
|
/*
|
||||||
const blacklist = await TwitterBlacklist.findOne({where: {userID:message.author.id}});
|
const blacklist = await TwitterBlacklist.findOne({where: {userID:message.author.id}});
|
||||||
|
|
||||||
if (blacklist) {
|
if (blacklist) {
|
||||||
return message.channel.send(`You have been blacklisted for the following reasons: \`${blacklist.get('reason')}\` be less naughty next time.`);
|
return message.channel.send(`You have been blacklisted for the following reasons: \`${blacklist.get('reason')}\` be less naughty next time.`);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// If account is less than 6 months old don't accept the tweet ( alt prevention )
|
// If account is less than 6 months old don't accept the tweet ( alt prevention )
|
||||||
if (message.author.createdAt > date.setMonth(date.getMonth() - 6)) {
|
if (message.author.createdAt > date.setMonth(date.getMonth() - 6)) {
|
||||||
return message.channel.send('Your account is too new to be able to use this command!');
|
return message.channel.send('Your account is too new to be able to use this command!');
|
||||||
|
@ -55,8 +58,12 @@ class tweetCommand extends Command {
|
||||||
if (args.text) {
|
if (args.text) {
|
||||||
// Detect banned word (Blacklist the user directly)
|
// Detect banned word (Blacklist the user directly)
|
||||||
if (wordToCensor.includes(args.text)) {
|
if (wordToCensor.includes(args.text)) {
|
||||||
const body = {userID: message.author.id, reason: 'Automatic ban from banned word.'};
|
const body = {type:'tweet', uid: message.author.id, reason: 'Automatic ban from banned word.'};
|
||||||
|
Blacklists.create(body);
|
||||||
|
/*
|
||||||
|
const body = {userID: message.author.id, reason: };
|
||||||
TwitterBlacklist.create(body);
|
TwitterBlacklist.create(body);
|
||||||
|
*/
|
||||||
return message.channel.send('Sike, you just posted cringe! Enjoy the blacklist :)');
|
return message.channel.send('Sike, you just posted cringe! Enjoy the blacklist :)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
const userBlacklist = require('../../models').userBlacklist;
|
const userBlacklist = require('../../models').userBlacklist;
|
||||||
|
const Blacklists = require('../../models').Blacklists;
|
||||||
|
|
||||||
class userBlacklistCommand extends Command {
|
class userBlacklistCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -9,12 +10,25 @@ class userBlacklistCommand extends Command {
|
||||||
ownerOnly: 'true',
|
ownerOnly: 'true',
|
||||||
userPermissions: ['MANAGE_MESSAGES'],
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
args: [
|
args: [
|
||||||
|
{
|
||||||
|
id: 'command',
|
||||||
|
type: 'string',
|
||||||
|
prompt: {
|
||||||
|
start: 'Which command do you want to get a user blacklisted from?'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'userID',
|
id: 'userID',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
prompt: {
|
prompt: {
|
||||||
start: 'Who do you want to blacklist?',
|
start: 'Who do you want to blacklist?',
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'reason',
|
||||||
|
type: 'string',
|
||||||
|
match: 'rest',
|
||||||
|
default: 'No reason specified.'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
channel: 'guild',
|
channel: 'guild',
|
||||||
|
@ -27,12 +41,13 @@ class userBlacklistCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
const blacklist = await userBlacklist.findOne({where: {userID:args.userID}});
|
const blacklist = await Blacklists.findOne({where: {type:args.command, uid:message.author.id}});
|
||||||
|
|
||||||
if (!blacklist) {
|
if (!blacklist) {
|
||||||
const body = {userID: args.userID};
|
const body = {type:args.command, uid: args.userID, reason: args.reason};
|
||||||
userBlacklist.create(body);
|
Blacklists.create(body);
|
||||||
return message.channel.send(`The following ID have been blacklisted globally: ${args.userID}`);
|
let user = this.client.users.resolve(args.userID);
|
||||||
|
return message.channel.send(`${user.tag} has been blacklisted from ${args.command} with the following reason ${args.reason}`);
|
||||||
} else {
|
} else {
|
||||||
message.channel.send('This user is already blacklisted, do you want to unblacklist him? y/n');
|
message.channel.send('This user is already blacklisted, do you want to unblacklist him? y/n');
|
||||||
const filter = m => m.content && m.author.id === message.author.id;
|
const filter = m => m.content && m.author.id === message.author.id;
|
||||||
|
@ -42,8 +57,8 @@ class userBlacklistCommand extends Command {
|
||||||
let messageContent = messages.map(messages => messages.content);
|
let messageContent = messages.map(messages => messages.content);
|
||||||
console.log(messageContent);
|
console.log(messageContent);
|
||||||
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||||||
userBlacklist.destroy({where: {userID:args.userID}});
|
Blacklists.destroy({where: {type:args.command, uid:args.userID}});
|
||||||
return message.channel.send(`The following ID have been unblacklisted globally: ${args.userID}`);
|
return message.channel.send(`The following ID have been unblacklisted from ${args.command}: ${args.userID}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -14,14 +14,14 @@ class removeytpCommand extends Command {
|
||||||
clientPermissions: ['SEND_MESSAGES'],
|
clientPermissions: ['SEND_MESSAGES'],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
id: 'filePath',
|
id: 'messageID',
|
||||||
type: 'string'
|
type: 'number'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
description: {
|
description: {
|
||||||
content: 'Delete a ytp',
|
content: 'Delete a ytp',
|
||||||
usage: '[file path]',
|
usage: '[message id]',
|
||||||
examples: ['./asset/ytp/userVid/something.mp4']
|
examples: ['some message id']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class removeytpCommand extends Command {
|
||||||
await ytpHash.destroy({where: {hash: hash}});
|
await ytpHash.destroy({where: {hash: hash}});
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.unlinkSync(args.filePath);
|
fs.unlinkSync(`./asset/ytp/userVid/${args.messageID}.mp4`);
|
||||||
return message.channel.send('Successfully removed the video.');
|
return message.channel.send('Successfully removed the video.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { Inhibitor } = require('discord-akairo');
|
const { Inhibitor } = require('discord-akairo');
|
||||||
const userBlacklist = require('../../models').userBlacklist;
|
const Blacklists = require('../../models').Blacklists;
|
||||||
|
|
||||||
class BlacklistInhibitor extends Inhibitor {
|
class BlacklistInhibitor extends Inhibitor {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -9,9 +9,8 @@ class BlacklistInhibitor extends Inhibitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message) {
|
async exec(message) {
|
||||||
//const blacklist = ['501856229123948545', '497730155691638784', '29476879240658944', '530399670728392737', '595102888796356628', '342039250302140418', '319180626928336896', '476412819278004236'];
|
|
||||||
|
|
||||||
const blacklist = await userBlacklist.findOne({where: {userID:message.author.id}});
|
const blacklist = await Blacklists.findOne({where: {type:'global', uid:message.author.id}});
|
||||||
|
|
||||||
if (blacklist) return true;
|
if (blacklist) return true;
|
||||||
}
|
}
|
||||||
|
|
18
event/inhibitors/commandBlacklist.js
Normal file
18
event/inhibitors/commandBlacklist.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
const { Inhibitor } = require('discord-akairo');
|
||||||
|
const Blacklists = require('../../models').Blacklists;
|
||||||
|
|
||||||
|
class commandblacklistInhibitor extends Inhibitor {
|
||||||
|
constructor() {
|
||||||
|
super('commandblacklist', {
|
||||||
|
reason: 'commandblacklist'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async exec(message, command) {
|
||||||
|
const blacklist = await Blacklists.findOne({where: {type:command.id, uid:message.author.id}});
|
||||||
|
|
||||||
|
if (blacklist) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = commandblacklistInhibitor;
|
|
@ -1,5 +1,6 @@
|
||||||
const { Inhibitor } = require('discord-akairo');
|
const { Inhibitor } = require('discord-akairo');
|
||||||
const commandblock = require('../../models').commandBlock;
|
const commandblock = require('../../models').commandBlock;
|
||||||
|
const commandblockuser = require('../../models').commandblockuser;
|
||||||
|
|
||||||
class commandblockInhibitor extends Inhibitor {
|
class commandblockInhibitor extends Inhibitor {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -11,8 +12,9 @@ class commandblockInhibitor extends Inhibitor {
|
||||||
async exec(message, command) {
|
async exec(message, command) {
|
||||||
if (message.channel.type == 'dm' || message.author.id == this.client.ownerID || message.member.hasPermission('ADMINISTRATOR')) return false;
|
if (message.channel.type == 'dm' || message.author.id == this.client.ownerID || message.member.hasPermission('ADMINISTRATOR')) return false;
|
||||||
const blacklist = await commandblock.findOne({where: {serverID:message.guild.id, command: command.id}});
|
const blacklist = await commandblock.findOne({where: {serverID:message.guild.id, command: command.id}});
|
||||||
|
const blocked = await commandblockuser.findOne({where: {serverID: message.guild.id, userID: message.author.id, command: command.id}});
|
||||||
|
|
||||||
if (blacklist) return true;
|
if (blacklist || blocked) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { Inhibitor } = require('discord-akairo');
|
const { Inhibitor } = require('discord-akairo');
|
||||||
const guildBlacklist = require('../../models').guildBlacklist;
|
const Blacklists = require('../../models').Blacklists;
|
||||||
|
|
||||||
class serverblacklistInhibitor extends Inhibitor {
|
class serverblacklistInhibitor extends Inhibitor {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -10,7 +10,8 @@ class serverblacklistInhibitor extends Inhibitor {
|
||||||
|
|
||||||
async exec(message) {
|
async exec(message) {
|
||||||
if (message.channel.type == 'dm') return;
|
if (message.channel.type == 'dm') return;
|
||||||
const blacklist = await guildBlacklist.findOne({where: {guildID:message.guild.id}});
|
|
||||||
|
const blacklist = await Blacklists.findOne({where: {type:'guild', uid:message.guild.id}});
|
||||||
|
|
||||||
if (blacklist) return true;
|
if (blacklist) return true;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const { Listener } = require('discord-akairo');
|
const { Listener } = require('discord-akairo');
|
||||||
|
const Blacklists = require('../../models').Blacklists;
|
||||||
|
|
||||||
class CommandBlockedListener extends Listener {
|
class CommandBlockedListener extends Listener {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -9,6 +10,7 @@ class CommandBlockedListener extends Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, command, reason) {
|
async exec(message, command, reason) {
|
||||||
|
const blacklist = await Blacklists.findOne({where: {type:command.id, uid:message.author.id}});
|
||||||
console.log(`${message.author.username} was blocked from using ${command.id} because of ${reason}!`);
|
console.log(`${message.author.username} was blocked from using ${command.id} because of ${reason}!`);
|
||||||
let ownerMessage;
|
let ownerMessage;
|
||||||
let blacklistMessage;
|
let blacklistMessage;
|
||||||
|
@ -47,6 +49,11 @@ class CommandBlockedListener extends Listener {
|
||||||
Embed.setDescription('The admins of this server blocked this command.');
|
Embed.setDescription('The admins of this server blocked this command.');
|
||||||
message.channel.send(Embed);
|
message.channel.send(Embed);
|
||||||
break;
|
break;
|
||||||
|
case 'commandblacklist':
|
||||||
|
Embed.setTitle('Command blocked.');
|
||||||
|
Embed.setDescription(`You've been blocked from this command for the following reason: \`${blacklist.reason}\``);
|
||||||
|
message.channel.send(Embed);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
33
migrations/20210313154536-create-blacklists.js
Normal file
33
migrations/20210313154536-create-blacklists.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
'use strict';
|
||||||
|
module.exports = {
|
||||||
|
up: async (queryInterface, Sequelize) => {
|
||||||
|
await queryInterface.createTable('Blacklists', {
|
||||||
|
id: {
|
||||||
|
allowNull: false,
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.INTEGER
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
},
|
||||||
|
uid: {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
},
|
||||||
|
reason: {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
down: async (queryInterface, Sequelize) => {
|
||||||
|
await queryInterface.dropTable('Blacklists');
|
||||||
|
}
|
||||||
|
};
|
33
migrations/20210313170727-create-commandblockuser.js
Normal file
33
migrations/20210313170727-create-commandblockuser.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
'use strict';
|
||||||
|
module.exports = {
|
||||||
|
up: async (queryInterface, Sequelize) => {
|
||||||
|
await queryInterface.createTable('commandblockusers', {
|
||||||
|
id: {
|
||||||
|
allowNull: false,
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.INTEGER
|
||||||
|
},
|
||||||
|
serverID: {
|
||||||
|
type: Sequelize.BIGINT
|
||||||
|
},
|
||||||
|
userID: {
|
||||||
|
type: Sequelize.BIGINT
|
||||||
|
},
|
||||||
|
command: {
|
||||||
|
type: Sequelize.STRING
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
down: async (queryInterface, Sequelize) => {
|
||||||
|
await queryInterface.dropTable('commandblockusers');
|
||||||
|
}
|
||||||
|
};
|
25
models/blacklists.js
Normal file
25
models/blacklists.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict';
|
||||||
|
const {
|
||||||
|
Model
|
||||||
|
} = require('sequelize');
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class Blacklists extends Model {
|
||||||
|
/**
|
||||||
|
* Helper method for defining associations.
|
||||||
|
* This method is not a part of Sequelize lifecycle.
|
||||||
|
* The `models/index` file will call this method automatically.
|
||||||
|
*/
|
||||||
|
static associate(models) {
|
||||||
|
// define association here
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Blacklists.init({
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
uid: DataTypes.STRING,
|
||||||
|
reason: DataTypes.STRING
|
||||||
|
}, {
|
||||||
|
sequelize,
|
||||||
|
modelName: 'Blacklists',
|
||||||
|
});
|
||||||
|
return Blacklists;
|
||||||
|
};
|
25
models/commandblockuser.js
Normal file
25
models/commandblockuser.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict';
|
||||||
|
const {
|
||||||
|
Model
|
||||||
|
} = require('sequelize');
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
class commandblockuser extends Model {
|
||||||
|
/**
|
||||||
|
* Helper method for defining associations.
|
||||||
|
* This method is not a part of Sequelize lifecycle.
|
||||||
|
* The `models/index` file will call this method automatically.
|
||||||
|
*/
|
||||||
|
static associate(models) {
|
||||||
|
// define association here
|
||||||
|
}
|
||||||
|
};
|
||||||
|
commandblockuser.init({
|
||||||
|
serverID: DataTypes.BIGINT,
|
||||||
|
userID: DataTypes.BIGINT,
|
||||||
|
command: DataTypes.STRING
|
||||||
|
}, {
|
||||||
|
sequelize,
|
||||||
|
modelName: 'commandblockuser',
|
||||||
|
});
|
||||||
|
return commandblockuser;
|
||||||
|
};
|
45
scripts/convertBlacklists.js
Normal file
45
scripts/convertBlacklists.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
const TwitterBlacklist = require('../models').TwitterBlacklist;
|
||||||
|
const ytpblacklist = require('../models').ytpblacklist;
|
||||||
|
const userBlacklist = require('../models').userBlacklist;
|
||||||
|
const guildBlacklist = require('../models').guildBlacklist;
|
||||||
|
const Blacklists = require('../models').Blacklists;
|
||||||
|
|
||||||
|
console.log('Starting conversions');
|
||||||
|
|
||||||
|
convert(userBlacklist, 'global');
|
||||||
|
convert(ytpblacklist, 'ytp');
|
||||||
|
convert(TwitterBlacklist, 'tweet');
|
||||||
|
convert(guildBlacklist, 'guild');
|
||||||
|
|
||||||
|
console.log('Conversion finished.');
|
||||||
|
|
||||||
|
async function convert(database, type) {
|
||||||
|
const prefix = `[${type}]`;
|
||||||
|
console.log(`${prefix} Starting conversion`);
|
||||||
|
let db = await database.findAll();
|
||||||
|
for (let dbKey in db) {
|
||||||
|
let reason = 'No reason specified.';
|
||||||
|
let uid;
|
||||||
|
|
||||||
|
if (db[dbKey].guildID != undefined)
|
||||||
|
uid = db[dbKey].guildID;
|
||||||
|
else
|
||||||
|
uid = db[dbKey].userID;
|
||||||
|
|
||||||
|
if (uid == undefined)
|
||||||
|
return console.error(`${prefix}: FATAL ERROR`);
|
||||||
|
|
||||||
|
if (db[dbKey].reason != undefined)
|
||||||
|
reason = db[dbKey].reason;
|
||||||
|
|
||||||
|
const body = {type: type, uid: uid, reason: reason};
|
||||||
|
|
||||||
|
Blacklists.findOrCreate({where: body, defaults: body})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(`${prefix}: ${err}`);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
console.log(`${prefix}: Successfully converted table`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
3
scripts/readme.md
Normal file
3
scripts/readme.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Various scripts for... things... idk
|
||||||
|
|
||||||
|
[ConvertBlacklists.js](convertBlacklists.js) - As the name imply, convert old blacklist format to the current one (as of 13.03.21)
|
Loading…
Reference in a new issue