forked from Supositware/Haha-Yes
Merge branch 'master' of https://gitlab.com/loicbersier/discordbot
This commit is contained in:
commit
7a1c55e935
5 changed files with 147 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -42,6 +42,7 @@ board/*.json
|
|||
tag/*.json
|
||||
welcome/*.json
|
||||
bye/*.json
|
||||
webhook/*.json
|
||||
json/censor.json
|
||||
json/uncensor.json
|
||||
|
||||
|
|
62
commands/fun/fakebot.js
Normal file
62
commands/fun/fakebot.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const fs = require('fs');
|
||||
const reload = require('auto-reload');
|
||||
|
||||
class fakebotCommand extends Command {
|
||||
constructor() {
|
||||
super('fakebot', {
|
||||
aliases: ['fakebot', 'fakeuser', 'fakemember'],
|
||||
category: 'fun',
|
||||
clientPermissions: ['MANAGE_WEBHOOKS'],
|
||||
args: [
|
||||
{
|
||||
id: 'member',
|
||||
type: 'user',
|
||||
prompt: {
|
||||
start: 'Who should i fake?',
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'message',
|
||||
type: 'string',
|
||||
prompt: {
|
||||
start: 'What message should i send?',
|
||||
},
|
||||
match: 'rest',
|
||||
}
|
||||
],
|
||||
description: {
|
||||
content: 'Fake a bot/user with webhook',
|
||||
usage: '',
|
||||
examples: ['']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
if (!fs.existsSync(`./webhook/${message.guild.id}_${message.channel.id}.json`)) {
|
||||
message.channel.createWebhook('fakebot')
|
||||
.then(webhook => {
|
||||
fs.writeFile(`./webhook/${message.guild.id}_${message.channel.id}.json`, `{"id": "${webhook.id}", "token": "${webhook.token}", "channel": "${message.channel.id}"}`, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
return message.channel.send('Please run me again to send the message!');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
let webhook = reload(`../../webhook/${message.guild.id}_${message.channel.id}.json`);
|
||||
this.client.fetchWebhook(webhook.id, webhook.token)
|
||||
.then(webhook => {
|
||||
webhook.edit({
|
||||
name: args.member.username,
|
||||
avatar: args.member.displayAvatarURL()
|
||||
});
|
||||
|
||||
message.delete();
|
||||
return webhook.send(args.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = fakebotCommand;
|
70
commands/fun/fakejoin.js
Normal file
70
commands/fun/fakejoin.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const fs = require('fs');
|
||||
const rand = require('../../rand.js');
|
||||
|
||||
class fakejoinCommand extends Command {
|
||||
constructor() {
|
||||
super('fakejoin', {
|
||||
aliases: ['fakejoin'],
|
||||
category: 'admin',
|
||||
channelRestriction: 'guild',
|
||||
args: [
|
||||
{
|
||||
id: 'member',
|
||||
type: 'string',
|
||||
match: 'rest'
|
||||
}
|
||||
],
|
||||
description: {
|
||||
content: 'Fake join message',
|
||||
usage: '[text]',
|
||||
examples: ['Supositware']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
if (fs.existsSync(`./welcome/${message.guild.id}.json`)) {
|
||||
let member;
|
||||
if (args.member) {
|
||||
member = args.member;
|
||||
} else {
|
||||
member = message.author.username;
|
||||
}
|
||||
|
||||
let welcome = require(`../../welcome/${message.guild.id}.json`);
|
||||
|
||||
const channel = this.client.channels.get(welcome['channel']);
|
||||
|
||||
let byeMessage = welcome['message'];
|
||||
|
||||
byeMessage = byeMessage.replace(/\[member\]/, member);
|
||||
byeMessage = byeMessage.replace(/\[server\]/, message.guild.name);
|
||||
|
||||
let attach;
|
||||
if (byeMessage.includes('[attach:')) {
|
||||
attach = byeMessage.split(/(\[attach:.*?])/);
|
||||
for (let i = 0, l = attach.length; i < l; i++) {
|
||||
if (attach[i].includes('[attach:')) {
|
||||
attach = attach[i].replace('[attach:', '').slice(0, -1);
|
||||
i = attach.length;
|
||||
}
|
||||
}
|
||||
byeMessage = byeMessage.replace(/(\[attach:.*?])/, '');
|
||||
}
|
||||
|
||||
byeMessage = rand.random(byeMessage);
|
||||
|
||||
message.delete();
|
||||
if (attach) {
|
||||
return channel.send(byeMessage, {files: [attach]});
|
||||
} else {
|
||||
return channel.send(byeMessage);
|
||||
}
|
||||
} else {
|
||||
return message.channel.send('The server need a join message first!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = fakejoinCommand;
|
|
@ -59,17 +59,27 @@ class MessageReactionAddListener extends Listener {
|
|||
channel = client.channels.get(shameboardChannel['shameboard']);
|
||||
}
|
||||
|
||||
const Embed = new MessageEmbed()
|
||||
let Embed = new MessageEmbed()
|
||||
.setColor(reaction.message.member.displayHexColor)
|
||||
.setAuthor(reaction.message.author.username, reaction.message.author.displayAvatarURL())
|
||||
.setDescription(messageContent)
|
||||
.addField('Jump to', `[message](https://discordapp.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id})`, true)
|
||||
.addField('Channel', reaction.message.channel, true)
|
||||
.setFooter(reaction.count + ' ' + emote)
|
||||
.setTimestamp();
|
||||
|
||||
return channel.send({files: messageAttachments, embed: Embed})
|
||||
.catch(() => channel.send(messageAttachments, { embed: Embed}));
|
||||
if (reaction.message.channel.nsfw) {
|
||||
Embed.setDescription(`||${messageContent}||`);
|
||||
if (messageAttachments != '') {
|
||||
return channel.send(`||${messageAttachments}||`, {embed: Embed});
|
||||
}
|
||||
else {
|
||||
return channel.send({embed: Embed});
|
||||
}
|
||||
} else {
|
||||
Embed.setDescription(messageContent);
|
||||
return channel.send({files: messageAttachments, embed: Embed})
|
||||
.catch(() => channel.send(messageAttachments, { embed: Embed}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
0
webhook/yes
Normal file
0
webhook/yes
Normal file
Loading…
Reference in a new issue