forked from Supositware/Haha-Yes
blacklist added for ytp
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
c883808c80
commit
2a966f9307
5 changed files with 89 additions and 7 deletions
|
@ -8,6 +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 MAX_CLIPS = 20;
|
const MAX_CLIPS = 20;
|
||||||
|
|
||||||
|
@ -164,6 +165,12 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.add) {
|
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
|
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;
|
||||||
if (!proxy[args.proxy]) args.proxy = 0;
|
if (!proxy[args.proxy]) args.proxy = 0;
|
||||||
|
@ -268,7 +275,6 @@ class ytpCommand extends Command {
|
||||||
|
|
||||||
let channel = this.client.channels.resolve(ytpChannel);
|
let channel = this.client.channels.resolve(ytpChannel);
|
||||||
return channel.send(url, {embed: Embed});
|
return channel.send(url, {embed: Embed});
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
|
|
65
commands/owner/YtpBlacklist.js
Normal file
65
commands/owner/YtpBlacklist.js
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
const { Command } = require('discord-akairo');
|
||||||
|
const ytpblacklist = require('../../models').ytpblacklist;
|
||||||
|
|
||||||
|
class ytpblacklistCommand extends Command {
|
||||||
|
constructor() {
|
||||||
|
super('ytpblacklist', {
|
||||||
|
aliases: ['YTPBlacklist', 'ytpblacklist', 'yblacklist'],
|
||||||
|
category: 'owner',
|
||||||
|
ownerOnly: 'true',
|
||||||
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
id: 'userID',
|
||||||
|
type: 'string',
|
||||||
|
prompt: {
|
||||||
|
start: 'Who do you want to blacklist?',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'reason',
|
||||||
|
match: 'rest',
|
||||||
|
type: 'string',
|
||||||
|
default: 'no reasons provided',
|
||||||
|
prompt: {
|
||||||
|
start: 'What should the reason be?',
|
||||||
|
optional: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
channel: 'guild',
|
||||||
|
description: {
|
||||||
|
content: 'Blacklist user from the YTP command',
|
||||||
|
usage: '[userID]',
|
||||||
|
examples: ['']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async exec(message, args) {
|
||||||
|
const blacklist = await ytpblacklist.findOne({where: {userID:args.userID}});
|
||||||
|
|
||||||
|
if (!blacklist) {
|
||||||
|
const body = {userID: args.userID, reason: args.reason};
|
||||||
|
ytpblacklist.create(body);
|
||||||
|
return message.channel.send(`The user with the following id have been blacklisted from the YTP: ${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;
|
||||||
|
message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] })
|
||||||
|
.then(messages => {
|
||||||
|
let messageContent = messages.map(messages => messages.content);
|
||||||
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||||||
|
ytpblacklist.destroy({where: {userID:args.userID}});
|
||||||
|
return message.channel.send(`The user with the following id have been unblacklisted from the YTP: ${args.userID}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
return message.channel.send('Took too long to answer. didin\'t unblacklist anyone.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ytpblacklistCommand;
|
|
@ -4,7 +4,7 @@ const userBlacklist = require('../../models').userBlacklist;
|
||||||
class userBlacklistCommand extends Command {
|
class userBlacklistCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('userBlacklist', {
|
super('userBlacklist', {
|
||||||
aliases: ['userblacklist'],
|
aliases: ['userblacklist', 'ublacklist'],
|
||||||
category: 'owner',
|
category: 'owner',
|
||||||
ownerOnly: 'true',
|
ownerOnly: 'true',
|
||||||
userPermissions: ['MANAGE_MESSAGES'],
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
|
@ -32,7 +32,7 @@ class userBlacklistCommand extends Command {
|
||||||
if (!blacklist) {
|
if (!blacklist) {
|
||||||
const body = {userID: args.userID};
|
const body = {userID: args.userID};
|
||||||
userBlacklist.create(body);
|
userBlacklist.create(body);
|
||||||
return message.channel.send(`The following ID have been blacklisted: ${args.userID}`);
|
return message.channel.send(`The following ID have been blacklisted globally: ${args.userID}`);
|
||||||
} 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;
|
||||||
|
@ -43,7 +43,7 @@ class userBlacklistCommand extends Command {
|
||||||
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}});
|
userBlacklist.destroy({where: {userID:args.userID}});
|
||||||
return message.channel.send(`The following ID have been unblacklisted: ${args.userID}`);
|
return message.channel.send(`The following ID have been unblacklisted globally: ${args.userID}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -42,16 +42,16 @@ class TwitterBlacklistCommand extends Command {
|
||||||
if (!blacklist) {
|
if (!blacklist) {
|
||||||
const body = {userID: args.userID, reason: args.reason};
|
const body = {userID: args.userID, reason: args.reason};
|
||||||
TwitterBlacklist.create(body);
|
TwitterBlacklist.create(body);
|
||||||
return message.channel.send(`The user with the following id have been blacklisted: ${args.userID}`);
|
return message.channel.send(`The user with the following id have been blacklisted from the twitter command: ${args.userID}`);
|
||||||
} 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;
|
||||||
message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] })
|
message.channel.awaitMessages(filter, {time: 5000 * 1000, max: 1, errors: ['time'] })
|
||||||
.then(messages => {
|
.then(messages => {
|
||||||
let messageContent = messages.map(messages => messages.content);
|
let messageContent = messages.map(messages => messages.content);
|
||||||
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||||||
TwitterBlacklist.destroy({where: {userID:args.userID}});
|
TwitterBlacklist.destroy({where: {userID:args.userID}});
|
||||||
return message.channel.send(`The user with the following id have been unblacklisted: ${args.userID}`);
|
return message.channel.send(`The user with the following id have been unblacklisted from the twitter command: ${args.userID}`);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
11
models/ytpblacklist.js
Normal file
11
models/ytpblacklist.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
'use strict';
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const ytpblacklist = sequelize.define('ytpblacklist', {
|
||||||
|
userID: DataTypes.BIGINT,
|
||||||
|
reason: DataTypes.STRING
|
||||||
|
}, {});
|
||||||
|
ytpblacklist.associate = function(models) {
|
||||||
|
// associations can be defined here
|
||||||
|
};
|
||||||
|
return ytpblacklist;
|
||||||
|
};
|
Loading…
Reference in a new issue