Compare commits

..

No commits in common. "02a858bf48b98c42f91ac577e3049edf4604dfb7" and "8863fa60509b2bce2c3d3cc9ac1a765db29e4459" have entirely different histories.

19 changed files with 22 additions and 289 deletions

View file

@ -1,52 +0,0 @@
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;

View file

@ -8,7 +8,7 @@ const downloader = require('../../utils/download');
const md5File = require('md5-file');
const ytpHash = require('../../models').ytpHash;
const { ytpChannel } = require('../../config.json');
//const ytpblacklist = require('../../models').ytpblacklist;
const ytpblacklist = require('../../models').ytpblacklist;
const MAX_CLIPS = 20;
@ -165,13 +165,11 @@ class ytpCommand extends Command {
}
if (args.add) {
/*
const blacklist = await ytpblacklist.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 next time.`);
}
*/
if (args.proxy && !args.proxyAuto) { // args.proxyAuto is only provided when the command is run after a error 429
args.proxy = args.proxy -1;

View file

@ -4,8 +4,7 @@ const fetch = require('node-fetch');
const os = require('os');
const fs = require('fs');
const rand = require('../../rand.js');
//const TwitterBlacklist = require('../../models').TwitterBlacklist;
const Blacklists = require('../../models').Blacklists;
const TwitterBlacklist = require('../../models').TwitterBlacklist;
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret, twiChannel } = require('../../config.json');
const wordToCensor = require('../../json/censor.json');
@ -38,13 +37,11 @@ class tweetCommand extends Command {
let date = new Date();
// 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 next time.`);
}
*/
// If account is less than 6 months old don't accept the tweet ( alt prevention )
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!');
@ -58,12 +55,8 @@ class tweetCommand extends Command {
if (args.text) {
// Detect banned word (Blacklist the user directly)
if (wordToCensor.includes(args.text)) {
const body = {type:'tweet', uid: message.author.id, reason: 'Automatic ban from banned word.'};
Blacklists.create(body);
/*
const body = {userID: message.author.id, reason: };
const body = {userID: message.author.id, reason: 'Automatic ban from banned word.'};
TwitterBlacklist.create(body);
*/
return message.channel.send('Sike, you just posted cringe! Enjoy the blacklist :)');
}

View file

@ -1,6 +1,5 @@
const { Command } = require('discord-akairo');
const userBlacklist = require('../../models').userBlacklist;
const Blacklists = require('../../models').Blacklists;
class userBlacklistCommand extends Command {
constructor() {
@ -10,25 +9,12 @@ class userBlacklistCommand extends Command {
ownerOnly: 'true',
userPermissions: ['MANAGE_MESSAGES'],
args: [
{
id: 'command',
type: 'string',
prompt: {
start: 'Which command do you want to get a user blacklisted from?'
}
},
{
id: 'userID',
type: 'string',
prompt: {
start: 'Who do you want to blacklist?',
}
},
{
id: 'reason',
type: 'string',
match: 'rest',
default: 'No reason specified.'
}
],
channel: 'guild',
@ -41,13 +27,12 @@ class userBlacklistCommand extends Command {
}
async exec(message, args) {
const blacklist = await Blacklists.findOne({where: {type:args.command, uid:message.author.id}});
const blacklist = await userBlacklist.findOne({where: {userID:args.userID}});
if (!blacklist) {
const body = {type:args.command, uid: args.userID, reason: args.reason};
Blacklists.create(body);
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}`);
const body = {userID: args.userID};
userBlacklist.create(body);
return message.channel.send(`The following ID have been blacklisted globally: ${args.userID}`);
} else {
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;
@ -57,8 +42,8 @@ class userBlacklistCommand extends Command {
let messageContent = messages.map(messages => messages.content);
console.log(messageContent);
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
Blacklists.destroy({where: {type:args.command, uid:args.userID}});
return message.channel.send(`The following ID have been unblacklisted from ${args.command}: ${args.userID}`);
userBlacklist.destroy({where: {userID:args.userID}});
return message.channel.send(`The following ID have been unblacklisted globally: ${args.userID}`);
}
})
.catch(err => {

View file

@ -14,14 +14,14 @@ class removeytpCommand extends Command {
clientPermissions: ['SEND_MESSAGES'],
args: [
{
id: 'messageID',
type: 'number'
id: 'filePath',
type: 'string'
}
],
description: {
content: 'Delete a ytp',
usage: '[message id]',
examples: ['some message id']
usage: '[file path]',
examples: ['./asset/ytp/userVid/something.mp4']
}
});
}
@ -34,7 +34,7 @@ class removeytpCommand extends Command {
await ytpHash.destroy({where: {hash: hash}});
}
fs.unlinkSync(`./asset/ytp/userVid/${args.messageID}.mp4`);
fs.unlinkSync(args.filePath);
return message.channel.send('Successfully removed the video.');
}
}

View file

@ -1,5 +1,5 @@
const { Inhibitor } = require('discord-akairo');
const Blacklists = require('../../models').Blacklists;
const userBlacklist = require('../../models').userBlacklist;
class BlacklistInhibitor extends Inhibitor {
constructor() {
@ -9,8 +9,9 @@ class BlacklistInhibitor extends Inhibitor {
}
async exec(message) {
const blacklist = await Blacklists.findOne({where: {type:'global', uid: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;
}

View file

@ -1,18 +0,0 @@
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;

View file

@ -1,6 +1,5 @@
const { Inhibitor } = require('discord-akairo');
const commandblock = require('../../models').commandBlock;
const commandblockuser = require('../../models').commandblockuser;
class commandblockInhibitor extends Inhibitor {
constructor() {
@ -12,9 +11,8 @@ class commandblockInhibitor extends Inhibitor {
async exec(message, command) {
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 blocked = await commandblockuser.findOne({where: {serverID: message.guild.id, userID: message.author.id, command: command.id}});
if (blacklist || blocked) return true;
if (blacklist) return true;
}
}

View file

@ -1,5 +1,5 @@
const { Inhibitor } = require('discord-akairo');
const Blacklists = require('../../models').Blacklists;
const guildBlacklist = require('../../models').guildBlacklist;
class serverblacklistInhibitor extends Inhibitor {
constructor() {
@ -10,8 +10,7 @@ class serverblacklistInhibitor extends Inhibitor {
async exec(message) {
if (message.channel.type == 'dm') return;
const blacklist = await Blacklists.findOne({where: {type:'guild', uid:message.guild.id}});
const blacklist = await guildBlacklist.findOne({where: {guildID:message.guild.id}});
if (blacklist) return true;

View file

@ -1,5 +1,4 @@
const { Listener } = require('discord-akairo');
const Blacklists = require('../../models').Blacklists;
class CommandBlockedListener extends Listener {
constructor() {
@ -10,7 +9,6 @@ class CommandBlockedListener extends Listener {
}
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}!`);
let ownerMessage;
let blacklistMessage;
@ -49,11 +47,6 @@ class CommandBlockedListener extends Listener {
Embed.setDescription('The admins of this server blocked this command.');
message.channel.send(Embed);
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;
}
}
}

View file

@ -1,33 +0,0 @@
'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');
}
};

View file

@ -1,33 +0,0 @@
'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');
}
};

View file

@ -1,25 +0,0 @@
'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;
};

View file

@ -1,25 +0,0 @@
'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;
};

View file

@ -1,45 +0,0 @@
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`);
});
}
}

View file

@ -1,3 +0,0 @@
# 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)