Merge branch 'master' of https://gitlab.com/loicbersier/discordbot
This commit is contained in:
commit
2d8c062dce
5 changed files with 113 additions and 34 deletions
|
@ -8,7 +8,7 @@ class fakebotCommand extends Command {
|
|||
clientPermissions: ['MANAGE_WEBHOOKS'],
|
||||
args: [
|
||||
{
|
||||
id: 'member',
|
||||
id: 'user',
|
||||
type: 'user',
|
||||
prompt: {
|
||||
start: 'Who should i fake?',
|
||||
|
@ -35,20 +35,28 @@ class fakebotCommand extends Command {
|
|||
async exec(message, args) {
|
||||
let Attachment = (message.attachments).array();
|
||||
let url;
|
||||
let username = args.user.username;
|
||||
let member = message.guild.members.get(args.user.id);
|
||||
// Get attachment link
|
||||
if (Attachment[0]) {
|
||||
url = Attachment[0].url;
|
||||
}
|
||||
// Show nickname if user is in guild
|
||||
if (member) {
|
||||
if (member.nickname) {
|
||||
username = member.nickname;
|
||||
}
|
||||
}
|
||||
|
||||
message.channel.createWebhook(args.member.username, {
|
||||
avatar: args.member.displayAvatarURL(),
|
||||
message.channel.createWebhook(username, {
|
||||
avatar: args.user.displayAvatarURL(),
|
||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||
})
|
||||
.then(webhook => {
|
||||
// Have to edit after creation otherwise the picture doesn't get applied
|
||||
webhook.edit({
|
||||
name: args.member.username,
|
||||
avatar: args.member.displayAvatarURL(),
|
||||
name: username,
|
||||
avatar: args.user.displayAvatarURL(),
|
||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||
});
|
||||
this.client.fetchWebhook(webhook.id, webhook.token)
|
||||
|
@ -61,7 +69,9 @@ class fakebotCommand extends Command {
|
|||
webhook.send(args.message);
|
||||
|
||||
setTimeout(() => {
|
||||
webhook.delete();
|
||||
webhook.delete({
|
||||
reason: `Fakebot/user command triggered by: ${message.author.username}`
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ class SayCommand extends Command {
|
|||
super('say', {
|
||||
aliases: ['say', 'sayd'],
|
||||
category: 'general',
|
||||
clientPermissions: ['SEND_MESSAGES', 'MANAGE_MESSAGES'],
|
||||
clientPermissions: ['SEND_MESSAGES'],
|
||||
args: [
|
||||
{
|
||||
id: 'text',
|
||||
|
@ -148,11 +148,18 @@ class SayCommand extends Command {
|
|||
// Send the final text
|
||||
if (attach) {
|
||||
if (message.util.parsed.alias == 'sayd')
|
||||
if (message.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
|
||||
message.delete();
|
||||
else
|
||||
message.channel.send('Im missing he `MANAGE_MESSAGES` perm to delete your message!');
|
||||
|
||||
return message.channel.send(text, {files: [attach]});
|
||||
} else {
|
||||
if (message.util.parsed.alias == 'sayd')
|
||||
if (message.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES'))
|
||||
message.delete();
|
||||
else
|
||||
message.channel.send('Im missing he `MANAGE_MESSAGES` perm to delete your message!');
|
||||
return message.channel.send(text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,27 +33,8 @@ class tweetCommand extends Command {
|
|||
}
|
||||
|
||||
async exec(message, args) {
|
||||
const client = this.client;
|
||||
let date = new Date();
|
||||
let Attachment = (message.attachments).array();
|
||||
|
||||
if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to tweet!');
|
||||
|
||||
let T = new Twit({
|
||||
consumer_key: twiConsumer,
|
||||
consumer_secret: twiConsumerSecret,
|
||||
access_token: twiToken,
|
||||
access_token_secret: twiTokenSecret
|
||||
});
|
||||
|
||||
/*
|
||||
// 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) {
|
||||
|
@ -70,6 +51,25 @@ class tweetCommand extends Command {
|
|||
return message.channel.send('Your account is too new to be able to use this command!');
|
||||
}
|
||||
|
||||
if (!Attachment[0] && !args.text) return message.channel.send('You need to input something for me to tweet!');
|
||||
|
||||
const client = this.client;
|
||||
|
||||
let T = new Twit({
|
||||
consumer_key: twiConsumer,
|
||||
consumer_secret: twiConsumerSecret,
|
||||
access_token: twiToken,
|
||||
access_token_secret: twiTokenSecret
|
||||
});
|
||||
|
||||
/*
|
||||
// Censor words
|
||||
let censor = reload('../../json/censor.json');
|
||||
let uncensor = reload('../../json/uncensor.json');
|
||||
filter.addWords(...censor);
|
||||
filter.removeWords(...uncensor);
|
||||
*/
|
||||
|
||||
// remove zero width space
|
||||
let text = '';
|
||||
if (args.text) {
|
||||
|
@ -83,12 +83,6 @@ class tweetCommand extends Command {
|
|||
text = rand.random(text, message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (text.length > 280) {
|
||||
return message.channel.send('Your message is more than the 280 characters limit!');
|
||||
}
|
||||
|
||||
try {
|
||||
// Make sure there is an attachment and if its an image
|
||||
if (Attachment[0]) {
|
||||
|
@ -148,6 +142,10 @@ class tweetCommand extends Command {
|
|||
|
||||
T.post('statuses/update', options, function (err, response) {
|
||||
if (err) {
|
||||
if (err.code == 88) return message.channel.send(err.message); // Rate limit exceeded
|
||||
if (err.code == 186) return message.channel.send(err.message); // Tweet needs to be a bit shorter.
|
||||
if (err.code == 187) return message.channel.send(err.message); // Status is a duplicate.
|
||||
if (err.code == 326) return message.channel.send(err.message); // To protect our users from spam and other malicious activity, this account is temporarily locked.
|
||||
console.error('OH NO!!!!');
|
||||
console.error(err);
|
||||
return message.channel.send('OH NO!!! AN ERROR HAS OCCURED!!! please hold on while i find what\'s causing this issue! ');
|
||||
|
@ -179,7 +177,6 @@ class tweetCommand extends Command {
|
|||
|
||||
channel = client.channels.get(twiChannel);
|
||||
channel.send({embed: Embed});
|
||||
|
||||
return message.channel.send(`Go see ur epic tweet https://twitter.com/i/status/${tweetid}`);
|
||||
});
|
||||
}
|
||||
|
|
65
commands/minigame/rps.js
Normal file
65
commands/minigame/rps.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
|
||||
class rpsCommand extends Command {
|
||||
constructor() {
|
||||
super('rps', {
|
||||
aliases: ['rps', 'rockpapersci'],
|
||||
category: 'minigame',
|
||||
clientPermissions: ['SEND_MESSAGES'],
|
||||
args: [
|
||||
{
|
||||
id: 'selection',
|
||||
type: 'string',
|
||||
match: 'rest',
|
||||
},
|
||||
],
|
||||
description: {
|
||||
content: 'Simply rock paper scissors\nCredit to: druid#0425 (276882603158798336)',
|
||||
usage: '[rock/paper/scissors]',
|
||||
examples: ['rock']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
let pcHand = Math.floor((Math.random()*3)+1);
|
||||
let playerHand = args.selection;
|
||||
|
||||
switch (playerHand) {
|
||||
case 'rock':
|
||||
if (pcHand==1) {
|
||||
message.channel.send('You both chose rock!');
|
||||
} else if (pcHand==2) {
|
||||
message.channel.send('The bot chose paper, you lose!');
|
||||
} else {
|
||||
message.channel.send('The bot chose scissors, you win!');
|
||||
}
|
||||
break;
|
||||
case 'paper':
|
||||
if (pcHand==1) {
|
||||
message.channel.send('You both chose paper!');
|
||||
} else if (pcHand==2) {
|
||||
message.channel.send('The bot chose scissors, you lose!');
|
||||
} else {
|
||||
message.channel.send('The bot chose rock, you win!');
|
||||
}
|
||||
break;
|
||||
case 'scissors':
|
||||
if (pcHand==1) {
|
||||
message.channel.send('You both chose scissors!');
|
||||
} else if (pcHand==2) {
|
||||
message.channel.send('The bot chose rock, you lose!');
|
||||
} else {
|
||||
message.channel.send('The bot chose paper, you win!');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
message.channel.send(`You entered ${playerHand} which is an incorrect choice.`);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = rpsCommand;
|
|
@ -12,7 +12,7 @@ class missingPermissionsListener extends Listener {
|
|||
switch(type) {
|
||||
case 'client':
|
||||
if (missing == 'SEND_MESSAGES') {
|
||||
return message.author.send(`Im missing the required permissions for this command!, \`${missing}\``);
|
||||
return;
|
||||
} else {
|
||||
message.reply(`Im missing the required permissions for this command!, \`${missing}\``);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue