-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from BluLightShow/develop
Merge v0.1.1
- Loading branch information
Showing
9 changed files
with
232 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
const { Command } = require('discord-akairo') | ||
const { MessageEmbed } = require('discord.js') | ||
const { embed } = require('../bot') | ||
|
||
class SayCommand extends Command { | ||
constructor() { | ||
super('say', { | ||
aliases: ['say'], | ||
description: '(For admins) Have the bot say something as an embed.', | ||
channel: 'guild', | ||
userPermissions: 'ADMINISTRATOR', | ||
argumentDefaults: { | ||
prompt: { | ||
time: 1200000 | ||
} | ||
}, | ||
args: [ | ||
{ | ||
id: 'channel', | ||
type: 'channel', | ||
prompt: { | ||
start: m => { | ||
return new MessageEmbed(embed) | ||
.setTitle('What channel would you like the message sent in?') | ||
.setTimestamp(new Date()) | ||
} | ||
} | ||
}, | ||
{ | ||
id: 'title', | ||
type: 'string', | ||
prompt: { | ||
start: m => { | ||
return new MessageEmbed(embed) | ||
.setTitle('What would you like the primary embed title to be?') | ||
} | ||
} | ||
}, | ||
{ | ||
id: 'description', | ||
type: 'string', | ||
prompt: { | ||
start: m => { | ||
return new MessageEmbed(embed) | ||
.setTitle('What would you like the primary embed description to be?') | ||
} | ||
} | ||
}, | ||
{ | ||
id: 'fields', | ||
type: 'string', | ||
prompt: { | ||
infinite: true, | ||
stopWord: 'done', | ||
start: m => { | ||
return new MessageEmbed(embed) | ||
.setTitle('What fields would you like to send? **Read below!!**') | ||
.setDescription('Please send **separate** messages alternating between the new field title and the new field value. Add as many fields as you want, and when you are ready to go to the next step, send the message "`done`". You have 20 minutes to complete this step.') | ||
.setTimestamp(new Date()) | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
} | ||
|
||
exec(message, args) { | ||
if ((args.fields.length % 2) !== 0) { | ||
return message.channel.send( | ||
new MessageEmbed(embed) | ||
.setTitle('No value was supplied for your final field. Every field must have a name and a value. Canceling command.') | ||
.setTimestamp(new Date()) | ||
) | ||
} | ||
message.channel.send( | ||
new MessageEmbed(embed) | ||
.setTitle('If you would like to add a thumbnail (small in top right), react with ✅. Otherwise react with ❌') | ||
.setTimestamp(new Date()) | ||
).then(m => { | ||
m.react('✅').then(() => { | ||
m.react('❌').then(() => { | ||
m.awaitReactions((reaction, user) => user === message.author, { max: 1, time: 300000 }).then(reactionCollection => { | ||
let reaction = reactionCollection.first() | ||
if (reaction.emoji.toString() === '✅') { | ||
message.channel.send( | ||
new MessageEmbed(embed) | ||
.setTitle('What thumbnail would you like to add? Please provide a direct URL.') | ||
.setTimestamp(new Date()) | ||
).then(() => { | ||
message.channel.awaitMessages(msg => msg.author === message.author, { max: 1, time: 300000}).then(msgCollector => { | ||
let msg = msgCollector.first() | ||
try { | ||
var url = new URL(msg.content) | ||
} catch (err) { | ||
return message.channel.send( | ||
new MessageEmbed(embed) | ||
.setTitle('URL provided was invalid. Canceling command.') | ||
.setTimestamp(new Date()) | ||
) | ||
} | ||
args.thumbnail = url.toString() | ||
sendIt(true) | ||
}) | ||
}) | ||
} else if (reaction.emoji.toString() === '❌') { | ||
sendIt(false) | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
function sendIt(thumbnail) { | ||
const say = new MessageEmbed(embed) | ||
.setTimestamp(new Date()) | ||
.setTitle(args.title).setDescription(args.description) | ||
|
||
// And that's on spending an hour realizing you can't iterate over an array you're modifying | ||
const iterableLength = args.fields.length | ||
|
||
for (let i = 0; i < iterableLength / 2; i++) { | ||
let name = args.fields.shift() | ||
let value = args.fields.shift() | ||
say.addField(name, value) | ||
} | ||
if (thumbnail) { | ||
say.setThumbnail(args.thumbnail) | ||
} | ||
message.guild.channels.resolve(args.channel).send(say).then(() => { | ||
message.channel.send( | ||
new MessageEmbed(embed) | ||
.setTimestamp(new Date()) | ||
.setTitle('Great success!') | ||
.setDescription('Embed sent.') | ||
) | ||
}).catch(err => { | ||
message.channel.send( | ||
new MessageEmbed(embed) | ||
.setTimestamp(new Date()) | ||
.setTitle('An error occured whilst trying to send.') | ||
.setDescription('Error: ' + err) | ||
) | ||
}) | ||
} | ||
} | ||
} | ||
module.exports = SayCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const { Command } = require('discord-akairo') | ||
const { MessageEmbed } = require('discord.js') | ||
const { embed } = require('../bot') | ||
|
||
class SetAvatarCommand extends Command { | ||
constructor() { | ||
super('setavatar', { | ||
aliases: ['setavatar', 'setpicture'], | ||
description: "(For admins) Sets the bot's profile picture.", | ||
userPermissions: 'ADMINISTRATOR', | ||
args: [ | ||
{ | ||
id: 'url', | ||
type: 'url' | ||
} | ||
] | ||
}) | ||
} | ||
|
||
exec(message, args) { | ||
this.client.user.setAvatar(args.url).then(() => { | ||
message.channel.send(new MessageEmbed(embed) | ||
.setTitle('Success') | ||
.setTimestamp(new Date()) | ||
) | ||
}) | ||
} | ||
} | ||
module.exports = SetAvatarCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters