return and await

This commit is contained in:
Daniel Odendahl Jr
2017-03-23 13:16:59 +00:00
parent cea110ce4b
commit 7c0a39ec5c
83 changed files with 295 additions and 264 deletions
+1 -1
View File
@@ -16,6 +16,6 @@ module.exports = class CanYouNot extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
message.channel.send('Can YOU not?');
return message.channel.send('Can YOU not?');
}
};
+1 -1
View File
@@ -20,6 +20,6 @@ module.exports = class GiveFlowerCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
message.channel.send('Ooh, what a pretty flower. What, I may have it? Thanks! I like flowers, yes? ♪');
return message.channel.send('Ooh, what a pretty flower. What, I may have it? Thanks! I like flowers, yes? ♪');
}
};
+1 -1
View File
@@ -16,6 +16,6 @@ module.exports = class LennyCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
message.channel.send('( ͡° ͜ʖ ͡°)');
return message.channel.send('( ͡° ͜ʖ ͡°)');
}
};
+2 -2
View File
@@ -18,10 +18,10 @@ module.exports = class LotteryCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
let lotteryNumber = ['Winner'][Math.floor(Math.random() * 100)];
if (lotteryNumber === "Winner") {
message.channel.send(`Wow ${message.author.username}! You actually won! Great job!`);
return message.channel.send(`Wow ${message.author.username}! You actually won! Great job!`);
}
else {
message.channel.send(`Nope, sorry ${message.author.username}, you lost.`);
return message.channel.send(`Nope, sorry ${message.author.username}, you lost.`);
}
}
};
+5 -5
View File
@@ -41,21 +41,21 @@ module.exports = class MathGameCommand extends commando.Command {
let randomExpression = randomValue1 + randomType + randomValue2;
let solved = math.eval(randomExpression);
if (!randomValue) {
message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
return message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
}
else {
const embed = new Discord.RichEmbed()
.setTitle('You have **ten** seconds to answer:')
.setDescription(randomExpression);
message.channel.sendEmbed(embed).then(() => {
message.channel.awaitMessages(response => response.content === solved.toString() && response.author.id === message.author.id, {
await message.channel.sendEmbed(embed).then(() => {
await message.channel.awaitMessages(response => response.content === solved.toString() && response.author.id === message.author.id, {
max: 1,
time: 10000,
errors: ['time'],
}).then((collected) => {
message.channel.send(`Good Job! You won!`);
return message.channel.send(`Good Job! You won!`);
}).catch(() => {
message.channel.send(`Aw... Too bad, try again next time! The correct answer was: ${solved}`);
return message.channel.send(`Aw... Too bad, try again next time! The correct answer was: ${solved}`);
});
});
}
+1 -1
View File
@@ -23,6 +23,6 @@ module.exports = class NitroCommand extends commando.Command {
.setColor(0x748BD9)
.setURL("https://discordapp.com/nitro")
.setDescription("This Message can only be viewed by members with Discord Nitro.\n\n\n[More Information](https://discordapp.com/nitro)");
message.channel.sendEmbed(embed).catch(console.error);
return message.channel.sendEmbed(embed).catch(console.error);
}
};
+1 -1
View File
@@ -16,6 +16,6 @@ module.exports = class SlowClapCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
console.log(`[Command] ${message.content}`);
message.channel.send('*slow clap*');
return message.channel.send('*slow clap*');
}
};
+29 -27
View File
@@ -23,49 +23,51 @@ module.exports = class SoundBoardCommand extends commando.Command {
console.log(`[Command] ${message.content}`);
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['CONNECT', 'SPEAK', 'ADD_REACTIONS'])) {
message.channel.send(':x: Error! In order to do this command, you must give me the permissions to "Connect" and "Speak", as well as the permission to Add Reactions!');
return message.channel.send(':x: Error! In order to do this command, you must give me the permissions to "Connect" and "Speak", as well as the permission to Add Reactions!');
}
else {
let voiceChannel = message.member.voiceChannel;
if (!voiceChannel) {
return message.channel.send(`:x: Error! Please be in a voice channel first!`);
}
let soundToPlay = message.content.toLowerCase().split(" ").slice(1).join(" ");
if (!soundToPlay) {
message.channel.send(':x: Error! No sound set. Please use ;soundboard list to see a list of sounds you can play.');
}
else if (soundToPlay === 'list') {
message.channel.send("**Available Sounds:** Cat, Pikachu, Vader, Doh, It's a Trap, Mario Death, Pokemon Center, Dun Dun Dun, Spongebob, Ugly Barnacle, Woo Hoo, Space, GLaDOS Bird, Airhorn, Zelda Chest, Eat my Shorts, No This is Patrick, Wumbo");
}
else if (soundToPlay === sounds.avaliable[soundToPlay]) {
let alreadyConnected = this.client.voiceConnections.get(voiceChannel.guild.id);
if (alreadyConnected) {
if (alreadyConnected.channel.id === voiceChannel.id) {
message.channel.send(':x: Error! I am already playing a sound!');
else {
let soundToPlay = message.content.toLowerCase().split(" ").slice(1).join(" ");
if (!soundToPlay) {
return message.channel.send(':x: Error! No sound set. Please use ;soundboard list to see a list of sounds you can play.');
}
else if (soundToPlay === 'list') {
return message.channel.send("**Available Sounds:** Cat, Pikachu, Vader, Doh, It's a Trap, Mario Death, Pokemon Center, Dun Dun Dun, Spongebob, Ugly Barnacle, Woo Hoo, Space, GLaDOS Bird, Airhorn, Zelda Chest, Eat my Shorts, No This is Patrick, Wumbo");
}
else if (soundToPlay === sounds.avaliable[soundToPlay]) {
let alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
if (alreadyConnected) {
if (alreadyConnected.channel.id === voiceChannel.id) {
return message.channel.send(':x: Error! I am already playing a sound!');
}
else {
return message.channel.send(':x: Error! I am already playing a sound!');
}
}
else {
message.channel.send(':x: Error! I am already playing a sound!');
await voiceChannel.join().then(connection => {
let stream = sounds.paths[soundToPlay];
let dispatcher = await connection.playStream(stream);
await message.react('🔊');
dispatcher.on('end', () => {
await message.react('✅');
return voiceChannel.leave();
});
});
}
}
else {
voiceChannel.join().then(connection => {
let stream = sounds.paths[soundToPlay];
let dispatcher = connection.playStream(stream);
message.react('🔊');
dispatcher.on('end', () => {
voiceChannel.leave();
message.react('✅');
});
});
return message.channel.send(':x: Error! Sound not found! Use `;soundboard list` to see a list of sounds you can play.');
}
}
else {
message.channel.send(':x: Error! Sound not found! Use `;soundboard list` to see a list of sounds you can play.');
}
}
}
else {
message.channel.send(':x: This is a DM!');
return message.channel.send(':x: This is a DM!');
}
}
};
+1 -1
View File
@@ -16,6 +16,6 @@ module.exports = class SpamCommand extends commando.Command {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'ATTACH_FILES'])) return;
}
console.log(`[Command] ${message.content}`);
message.channel.sendFile("./images/Spam.jpg");
return message.channel.sendFile("./images/Spam.jpg");
}
};
+5 -5
View File
@@ -51,21 +51,21 @@ module.exports = class TypingGameCommand extends commando.Command {
break;
}
if (!time) {
message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
return message.channel.send(':x: Error! No difficulty set! (Choose Easy, Medium, Hard, or Extreme)');
}
else {
const embed = new Discord.RichEmbed()
.setTitle('You have **' + levelWord + '** seconds to type:')
.setDescription(randomSentence);
message.channel.sendEmbed(embed).then(() => {
message.channel.awaitMessages(response => response.content === randomSentence && response.author.id === message.author.id, {
await message.channel.sendEmbed(embed).then(() => {
await message.channel.awaitMessages(response => response.content === randomSentence && response.author.id === message.author.id, {
max: 1,
time: time,
errors: ['time'],
}).then((collected) => {
message.channel.send(`Good Job! You won!`);
return message.channel.send(`Good Job! You won!`);
}).catch(() => {
message.channel.send('Aw... Too bad, try again next time!');
return message.channel.send('Aw... Too bad, try again next time!');
});
});
}