mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
The Power of const
This commit is contained in:
@@ -26,11 +26,11 @@ module.exports = class RemindCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let remindMe = args.remind;
|
||||
const remindMe = args.remind;
|
||||
try {
|
||||
let remindTime = sherlock.parse(remindMe);
|
||||
let time = remindTime.startDate.getTime() - Date.now();
|
||||
let preRemind = await message.say(`I will remind you '${remindTime.eventTitle}' ${moment().add(time, 'ms').fromNow()}.`);
|
||||
const remindTime = sherlock.parse(remindMe);
|
||||
const time = remindTime.startDate.getTime() - Date.now();
|
||||
const preRemind = await message.say(`I will remind you '${remindTime.eventTitle}' ${moment().add(time, 'ms').fromNow()}.`);
|
||||
const remindMessage = await new Promise(resolve => {
|
||||
setTimeout(() => resolve(message.say(`${message.author} you wanted me to remind you of: '${remindTime.eventTitle}'`)), time);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
const commando = require('discord.js-commando');
|
||||
const sounds = require('./sounds.json');
|
||||
const 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'];
|
||||
const paths = {
|
||||
"cat": "./sounds/cat.mp3",
|
||||
"pikachu": "./sounds/pikachu.mp3",
|
||||
"vader": "./sounds/vader.mp3",
|
||||
"doh": "./sounds/doh.mp3",
|
||||
"it's a trap": "./sounds/its-a-trap.mp3",
|
||||
"mario death": "./sounds/mario-death.mp3",
|
||||
"pokemon center": "./sounds/pokemon-center.mp3",
|
||||
"dun dun dun": "./sounds/dun-dun-dun.mp3",
|
||||
"spongebob": "./sounds/spongebob.mp3",
|
||||
"ugly barnacle": "./sounds/ugly-barnacle.mp3",
|
||||
"woo hoo": "./sounds/woohoo.mp3",
|
||||
"space": "./sounds/space.mp3",
|
||||
"glados bird": "./sounds/glados-bird.mp3",
|
||||
"airhorn": "./sounds/airhorn.mp3",
|
||||
"zelda chest": "./sounds/zelda-chest.mp3",
|
||||
"eat my shorts": "./sounds/eat-my-shorts.mp3",
|
||||
"no this is patrick": "./sounds/no-this-is-patrick.mp3",
|
||||
"wumbo": "./sounds/wumbo.mp3"
|
||||
};
|
||||
|
||||
module.exports = class SoundBoardCommand extends commando.Command {
|
||||
constructor(Client) {
|
||||
@@ -20,7 +40,7 @@ module.exports = class SoundBoardCommand extends commando.Command {
|
||||
prompt: 'What sound do you want me to play?',
|
||||
type: 'string',
|
||||
validate: sound => {
|
||||
if (sounds.avaliable[sound.toLowerCase()]) {
|
||||
if (sounds.some(soundArray => sound.toLowerCase() === soundArray)) {
|
||||
return true;
|
||||
}
|
||||
return 'Sound not found. Use `;help soundboard` to view a list of sounds.';
|
||||
@@ -34,17 +54,17 @@ module.exports = class SoundBoardCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'CONNECT', 'SPEAK', 'ADD_REACTIONS'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let voiceChannel = message.member.voiceChannel;
|
||||
const voiceChannel = message.member.voiceChannel;
|
||||
if (!voiceChannel) return message.say(`:x: Error! Please be in a voice channel first!`);
|
||||
let soundToPlay = args.sound.toLowerCase();
|
||||
let alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
|
||||
const soundToPlay = args.sound.toLowerCase();
|
||||
const alreadyConnected = await this.client.voiceConnections.get(voiceChannel.guild.id);
|
||||
if (alreadyConnected) {
|
||||
if (alreadyConnected.channel.id === voiceChannel.id) return message.say(':x: Error! I am already playing a sound!');
|
||||
return message.say(':x: Error! I am already playing a sound!');
|
||||
}
|
||||
let connection = await voiceChannel.join();
|
||||
let stream = sounds.paths[soundToPlay];
|
||||
let dispatcher = connection.playStream(stream);
|
||||
const connection = await voiceChannel.join();
|
||||
const stream = paths[soundToPlay];
|
||||
const dispatcher = connection.playStream(stream);
|
||||
message.react('🔊');
|
||||
dispatcher.on('end', () => {
|
||||
message.react('✅');
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"avaliable": {
|
||||
"cat": "cat",
|
||||
"pikachu": "pikachu",
|
||||
"vader": "vader",
|
||||
"doh": "doh",
|
||||
"it's a trap": "it's a trap",
|
||||
"mario death": "mario death",
|
||||
"pokemon center": "pokemon center",
|
||||
"dun dun dun": "dun dun dun",
|
||||
"spongebob": "spongebob",
|
||||
"ugly barnacle": "ugly barnacle",
|
||||
"woo hoo": "woo hoo",
|
||||
"space": "space",
|
||||
"glados bird": "glados bird",
|
||||
"airhorn": "airhorn",
|
||||
"zelda chest": "zelda chest",
|
||||
"eat my shorts": "eat my shorts",
|
||||
"no this is patrick": "no this is patrick",
|
||||
"wumbo": "wumbo"
|
||||
},
|
||||
"paths": {
|
||||
"cat": "./sounds/cat.mp3",
|
||||
"pikachu": "./sounds/pikachu.mp3",
|
||||
"vader": "./sounds/vader.mp3",
|
||||
"doh": "./sounds/doh.mp3",
|
||||
"it's a trap": "./sounds/its-a-trap.mp3",
|
||||
"mario death": "./sounds/mario-death.mp3",
|
||||
"pokemon center": "./sounds/pokemon-center.mp3",
|
||||
"dun dun dun": "./sounds/dun-dun-dun.mp3",
|
||||
"spongebob": "./sounds/spongebob.mp3",
|
||||
"ugly barnacle": "./sounds/ugly-barnacle.mp3",
|
||||
"woo hoo": "./sounds/woohoo.mp3",
|
||||
"space": "./sounds/space.mp3",
|
||||
"glados bird": "./sounds/glados-bird.mp3",
|
||||
"airhorn": "./sounds/airhorn.mp3",
|
||||
"zelda chest": "./sounds/zelda-chest.mp3",
|
||||
"eat my shorts": "./sounds/eat-my-shorts.mp3",
|
||||
"no this is patrick": "./sounds/no-this-is-patrick.mp3",
|
||||
"wumbo": "./sounds/wumbo.mp3"
|
||||
}
|
||||
}
|
||||
@@ -45,18 +45,18 @@ module.exports = class StrawpollCommand extends commando.Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
console.log(`[Command] ${message.content}`);
|
||||
let title = args.title;
|
||||
let choices = args.choices.split(" | ");
|
||||
const title = args.title;
|
||||
const choices = args.choices.split(" | ");
|
||||
if (choices.length < 2) return message.say(':x: Error! You provided less than two choices!');
|
||||
if (choices.length > 31) return message.say(':x: Error! You provided more than thirty choices!');
|
||||
try {
|
||||
let response = await request
|
||||
const response = await request
|
||||
.post('https://strawpoll.me/api/v2/polls')
|
||||
.send({
|
||||
title: title,
|
||||
options: choices
|
||||
});
|
||||
let data = response.body;
|
||||
const data = response.body;
|
||||
return message.say(`${data.title}\nhttp://strawpoll.me/${data.id}`);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -22,15 +22,15 @@ module.exports = class TodayCommand extends commando.Command {
|
||||
}
|
||||
console.log("[Command] " + message.content);
|
||||
try {
|
||||
let response = await request
|
||||
const response = await request
|
||||
.get('http://history.muffinlabs.com/date')
|
||||
.set({
|
||||
'Accept': 'application/json'
|
||||
})
|
||||
.buffer(true);
|
||||
let parsedResponse = JSON.parse(response.text);
|
||||
let events = parsedResponse.data.Events;
|
||||
let randomNumber = Math.floor(Math.random() * events.length);
|
||||
const parsedResponse = JSON.parse(response.text);
|
||||
const events = parsedResponse.data.Events;
|
||||
const randomNumber = Math.floor(Math.random() * events.length);
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x9797FF)
|
||||
.setURL(parsedResponse.url)
|
||||
|
||||
Reference in New Issue
Block a user