mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-09 01:04:16 +02:00
timer, opinion, bug fixes
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"critic": {
|
||||
"certified": "<:certified_fresh:391778461951459339>",
|
||||
"fresh": "<:red_tomato:391778462974607360>",
|
||||
"rotten": "<:splat_tomato:391778462194728961>"
|
||||
},
|
||||
"audience": {
|
||||
"Upright": "<:standing_popcorn:391778463045910538>",
|
||||
"Spilled": "<:tipped_popcorn:391778462312169472>"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { wait } = require('../../util/Util');
|
||||
|
||||
module.exports = class TimerCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'timer',
|
||||
group: 'other',
|
||||
memberName: 'timer',
|
||||
description: 'Sets a timer for a certain amount of time.',
|
||||
args: [
|
||||
{
|
||||
key: 'seconds',
|
||||
prompt: 'How many seconds do you want to set a timer for?',
|
||||
type: 'float',
|
||||
min: 1,
|
||||
max: 600
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.timers = new Set();
|
||||
}
|
||||
|
||||
async run(msg, { seconds }) {
|
||||
if (this.timers.has(msg.author.id)) return msg.reply('You can only have one timer at a time.');
|
||||
this.timers.add(msg.author.id);
|
||||
await msg.say(`Setting a timer for ${seconds} seconds...`);
|
||||
await wait(seconds / 1000);
|
||||
this.timers.delete(msg.author.id);
|
||||
return msg.reply('Time\'s up!');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const opinions = ['👍', '👎'];
|
||||
|
||||
module.exports = class OpinionCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'opinion',
|
||||
aliases: ['sex'],
|
||||
group: 'random',
|
||||
memberName: 'opinion',
|
||||
description: 'Determines the opinion on something.',
|
||||
args: [
|
||||
{
|
||||
key: 'question',
|
||||
prompt: 'What do you want to get an opinion on?',
|
||||
type: 'string',
|
||||
max: 1950
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { question }) {
|
||||
return msg.say(stripIndents`
|
||||
${question}
|
||||
${opinions[Math.floor(Math.random() * opinions.length)]}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -16,7 +16,7 @@ module.exports = class GoogleCommand extends Command {
|
||||
prompt: 'What would you like to search for?',
|
||||
type: 'string',
|
||||
validate: query => {
|
||||
if (encodeURIComponent(query).length < 1973) return true;
|
||||
if (encodeURIComponent(query).length < 1950) return true;
|
||||
return 'Invalid query, your query is too long.';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class MapCommand extends Command {
|
||||
prompt: 'What location would you like to get a map of?',
|
||||
type: 'string',
|
||||
validate: location => {
|
||||
if (encodeURIComponent(location).length < 1965) return true;
|
||||
if (encodeURIComponent(location).length < 1950) return true;
|
||||
return 'Invalid location, your location is too long.';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { shorten } = require('../../util/Util');
|
||||
const { critic, audience } = require('../../assets/json/rotten-tomatoes');
|
||||
|
||||
module.exports = class RottenTomatoesCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -36,8 +35,8 @@ module.exports = class RottenTomatoesCommand extends Command {
|
||||
const urlID = find.url.replace('/m/', '');
|
||||
const { text } = await snekfetch.get(`https://www.rottentomatoes.com/api/private/v1.0/movies/${urlID}`);
|
||||
const body = JSON.parse(text);
|
||||
const criticS = body.ratingSummary.allCritics;
|
||||
const audienceS = body.ratingSummary.audience;
|
||||
const criticScore = body.ratingSummary.allCritics;
|
||||
const audienceScore = body.ratingSummary.audience;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFFEC02)
|
||||
.setTitle(`${body.title} (${body.year})`)
|
||||
@@ -46,9 +45,9 @@ module.exports = class RottenTomatoesCommand extends Command {
|
||||
.setDescription(shorten(body.ratingSummary.consensus))
|
||||
.setThumbnail(body.posters.original)
|
||||
.addField('❯ Critic Score',
|
||||
criticS.meterValue ? `${critic[criticS.meterClass]} ${criticS.meterValue}%` : '???', true)
|
||||
criticScore.meterValue ? `${criticScore.meterValue}%` : '???', true)
|
||||
.addField('❯ Audience Score',
|
||||
audienceS.meterScore ? `${audience[body.ratings.audience_rating]} ${audienceS.meterScore}%` : '???', true);
|
||||
audienceScore.meterScore ? `${audienceScore.meterScore}%` : '???', true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = class LMGTFYCommand extends Command {
|
||||
prompt: 'What would you like the link to search for?',
|
||||
type: 'string',
|
||||
validate: query => {
|
||||
if (encodeURIComponent(query).length < 1973) return true;
|
||||
if (encodeURIComponent(query).length < 1950) return true;
|
||||
return 'Invalid query, your query is too long.';
|
||||
},
|
||||
parse: query => encodeURIComponent(query)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MOCKING_EMOJI_ID } = process.env;
|
||||
|
||||
module.exports = class MockingCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -23,7 +24,7 @@ module.exports = class MockingCommand extends Command {
|
||||
|
||||
run(msg, { text }) {
|
||||
for (let i = 0; i < text.length; i += Math.floor(Math.random() * 4)) text[i] = text[i].toUpperCase();
|
||||
return msg.say(`${text.join('')} <:sponge:390141884070363138>`);
|
||||
return msg.say(`${text.join('')} <:mocking:${MOCKING_EMOJI_ID}>`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "66.5.2",
|
||||
"version": "66.6.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user