mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-12 00:04:48 +02:00
fire, percentage, units
This commit is contained in:
@@ -8,7 +8,7 @@ Xiao is a Discord bot coded in JavaScript with
|
|||||||
300 commands, she is one of the most feature-filled bots out there, and formerly
|
300 commands, she is one of the most feature-filled bots out there, and formerly
|
||||||
served over 10,000 servers with a uniquely devoted fanbase.
|
served over 10,000 servers with a uniquely devoted fanbase.
|
||||||
|
|
||||||
## Commands (283)
|
## Commands (285)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **prefix**: Shows or sets the command prefix.
|
* **prefix**: Shows or sets the command prefix.
|
||||||
@@ -179,7 +179,7 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
|||||||
* **gunfight**: Engage in a western gunfight against another user. High noon.
|
* **gunfight**: Engage in a western gunfight against another user. High noon.
|
||||||
* **hangman**: Prevent a man from being hanged by guessing a word as fast as you can.
|
* **hangman**: Prevent a man from being hanged by guessing a word as fast as you can.
|
||||||
* **hunger-games**: Simulate a Hunger Games match with up to 24 tributes.
|
* **hunger-games**: Simulate a Hunger Games match with up to 24 tributes.
|
||||||
* **lottery**: Attempt to win the lottery, with a 1 in 1000 chance of winning.
|
* **lottery**: Attempt to win the lottery with 6 numbers.
|
||||||
* **math-quiz**: See how fast you can answer a math problem in a given time limit.
|
* **math-quiz**: See how fast you can answer a math problem in a given time limit.
|
||||||
* **quiz**: Answer a quiz question.
|
* **quiz**: Answer a quiz question.
|
||||||
* **rock-paper-scissors**: Play Rock-Paper-Scissors.
|
* **rock-paper-scissors**: Play Rock-Paper-Scissors.
|
||||||
@@ -228,6 +228,7 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
|||||||
* **challenger**: Draws a user's avatar over Super Smash Bros.'s "Challenger Approaching" screen.
|
* **challenger**: Draws a user's avatar over Super Smash Bros.'s "Challenger Approaching" screen.
|
||||||
* **dexter**: Draws a user's avatar over the screen of Dexter from Pokémon.
|
* **dexter**: Draws a user's avatar over the screen of Dexter from Pokémon.
|
||||||
* **distracted-boyfriend**: Draws three user's avatars over the "Distracted Boyfriend" meme.
|
* **distracted-boyfriend**: Draws three user's avatars over the "Distracted Boyfriend" meme.
|
||||||
|
* **fire**: Draws a fiery border over a user's avatar.
|
||||||
* **food-broke**: Draws a user's avatar over the "Food Broke" meme.
|
* **food-broke**: Draws a user's avatar over the "Food Broke" meme.
|
||||||
* **hat**: Draws a hat over a user's avatar.
|
* **hat**: Draws a hat over a user's avatar.
|
||||||
* **he-lives-in-you**: Draws a user's avatar over Simba from The Lion King's reflection.
|
* **he-lives-in-you**: Draws a user's avatar over Simba from The Lion King's reflection.
|
||||||
@@ -291,8 +292,9 @@ served over 10,000 servers with a uniquely devoted fanbase.
|
|||||||
* **currency**: Converts money from one currency to another.
|
* **currency**: Converts money from one currency to another.
|
||||||
* **final-grade-calculator**: Determines the grade you need to make on your final to get your desired course grade.
|
* **final-grade-calculator**: Determines the grade you need to make on your final to get your desired course grade.
|
||||||
* **math**: Evaluates a math expression.
|
* **math**: Evaluates a math expression.
|
||||||
|
* **percentage**: Determines the percentage one number is of another.
|
||||||
* **roman-numeral**: Converts a number to roman numerals.
|
* **roman-numeral**: Converts a number to roman numerals.
|
||||||
* **temperature**: Converts temperatures to/from celsius, fahrenheit, or kelvin.
|
* **units**: Converts units to/from other units.
|
||||||
|
|
||||||
### Role Management:
|
### Role Management:
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 517 KiB |
@@ -0,0 +1,46 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
const path = require('path');
|
||||||
|
const { drawImageWithTint } = require('../../util/Canvas');
|
||||||
|
|
||||||
|
module.exports = class FireCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'fire',
|
||||||
|
aliases: ['flame'],
|
||||||
|
group: 'avatar-edit',
|
||||||
|
memberName: 'fire',
|
||||||
|
description: 'Draws a fiery border over a user\'s avatar.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
prompt: 'Which user would you like to edit the avatar of?',
|
||||||
|
type: 'user',
|
||||||
|
default: msg => msg.author
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { user }) {
|
||||||
|
const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
|
try {
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'fire.png'));
|
||||||
|
const { body } = await snekfetch.get(avatarURL);
|
||||||
|
const avatar = await loadImage(body);
|
||||||
|
const canvas = createCanvas(avatar.width, avatar.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
drawImageWithTint(ctx, avatar, '#fc671e', 0, 0, avatar.width, avatar.height);
|
||||||
|
ctx.drawImage(base, 0, 0, avatar.width, avatar.height);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'fire.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -64,7 +64,7 @@ module.exports = class AkinatorCommand extends Command {
|
|||||||
|
|
||||||
async createSession(channel) {
|
async createSession(channel) {
|
||||||
const { body } = await snekfetch
|
const { body } = await snekfetch
|
||||||
.get('http://api-us1.akinator.com/ws/new_session')
|
.get('http://api-en1.akinator.com/ws/new_session')
|
||||||
.query({
|
.query({
|
||||||
partner: 1,
|
partner: 1,
|
||||||
player: 'xiaobot'
|
player: 'xiaobot'
|
||||||
@@ -83,7 +83,7 @@ module.exports = class AkinatorCommand extends Command {
|
|||||||
async progress(channel, answer) {
|
async progress(channel, answer) {
|
||||||
const session = this.sessions.get(channel.id);
|
const session = this.sessions.get(channel.id);
|
||||||
const { body } = await snekfetch
|
const { body } = await snekfetch
|
||||||
.get('http://api-us1.akinator.com/ws/answer')
|
.get('http://api-en1.akinator.com/ws/answer')
|
||||||
.query({
|
.query({
|
||||||
session: session.id,
|
session: session.id,
|
||||||
signature: session.signature,
|
signature: session.signature,
|
||||||
@@ -104,7 +104,7 @@ module.exports = class AkinatorCommand extends Command {
|
|||||||
async finish(channel) {
|
async finish(channel) {
|
||||||
const session = this.sessions.get(channel.id);
|
const session = this.sessions.get(channel.id);
|
||||||
const { body } = await snekfetch
|
const { body } = await snekfetch
|
||||||
.get('http://api-us1.akinator.com/ws/list')
|
.get('http://api-en1.akinator.com/ws/list')
|
||||||
.query({
|
.query({
|
||||||
session: session.id,
|
session: session.id,
|
||||||
signature: session.signature,
|
signature: session.signature,
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
|
||||||
|
module.exports = class PercentageCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'percentage',
|
||||||
|
aliases: ['percent'],
|
||||||
|
group: 'number-edit',
|
||||||
|
memberName: 'percentage',
|
||||||
|
description: 'Determines the percentage one number is of another.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'amount',
|
||||||
|
prompt: 'How much of the maximum value should be used?',
|
||||||
|
type: 'float'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'maximum',
|
||||||
|
prompt: 'What is the maximum value of the percentage?',
|
||||||
|
type: 'float'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(msg, { amount, maximum }) {
|
||||||
|
const percentage = (amount / maximum) * 100;
|
||||||
|
return msg.say(`${amount} is ${percentage}% of ${maximum}.`);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
|
||||||
const { list } = require('../../util/Util');
|
|
||||||
const units = ['celsius', 'fahrenheit', 'kelvin'];
|
|
||||||
|
|
||||||
module.exports = class TemperatureCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'temperature',
|
|
||||||
aliases: ['temperature-convert', 'convert-temperature', 'temp-convert', 'convert-temp'],
|
|
||||||
group: 'number-edit',
|
|
||||||
memberName: 'temperature',
|
|
||||||
description: `Converts temperatures to/from ${list(units, 'or')}.`,
|
|
||||||
details: `**Units**: ${units.join(', ')}`,
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
key: 'base',
|
|
||||||
prompt: `What temperature unit do you want to use as the base? Either ${list(units, 'or')}.`,
|
|
||||||
type: 'string',
|
|
||||||
validate: base => {
|
|
||||||
if (units.includes(base.toLowerCase())) return true;
|
|
||||||
return `Invalid base, please enter either ${list(units, 'or')}.`;
|
|
||||||
},
|
|
||||||
parse: base => base.toLowerCase()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'target',
|
|
||||||
prompt: `What temperature unit do you want to convert to? Either ${list(units, 'or')}.`,
|
|
||||||
type: 'string',
|
|
||||||
validate: target => {
|
|
||||||
if (units.includes(target.toLowerCase())) return true;
|
|
||||||
return `Invalid target, please enter either ${list(units, 'or')}.`;
|
|
||||||
},
|
|
||||||
parse: target => target.toLowerCase()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'amount',
|
|
||||||
prompt: 'What temperature should be converted?',
|
|
||||||
type: 'float'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run(msg, { base, target, amount }) { // eslint-disable-line consistent-return
|
|
||||||
if (base === target) return msg.say(`Converting ${base} to ${target} is the same value, dummy.`);
|
|
||||||
if (base === 'celsius') {
|
|
||||||
if (target === 'fahrenheit') return msg.say(`${amount}°C is ${(amount * 1.8) + 32}°F.`);
|
|
||||||
if (target === 'kelvin') return msg.say(`${amount}°C is ${amount + 273.15}°K.`);
|
|
||||||
}
|
|
||||||
if (base === 'fahrenheit') {
|
|
||||||
if (target === 'celsius') return msg.say(`${amount}°F is ${(amount - 32) / 1.8}°C.`);
|
|
||||||
if (target === 'kelvin') return msg.say(`${amount}°F is ${(amount + 459.67) * (5 / 9)}°K.`);
|
|
||||||
}
|
|
||||||
if (base === 'kelvin') {
|
|
||||||
if (target === 'celsius') return msg.say(`${amount}°K is ${amount - 273.15}°C.`);
|
|
||||||
if (target === 'fahrenheit') return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const math = require('mathjs');
|
||||||
|
|
||||||
|
module.exports = class UnitsCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'units',
|
||||||
|
aliases: ['convert-units', 'unit-converter'],
|
||||||
|
group: 'number-edit',
|
||||||
|
memberName: 'units',
|
||||||
|
description: 'Converts units to/from other units.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'base',
|
||||||
|
prompt: 'What unit type do you want to convert from?',
|
||||||
|
type: 'string',
|
||||||
|
parse: base => base.toLowerCase()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'target',
|
||||||
|
prompt: 'What unit type do you want to convert to?',
|
||||||
|
type: 'string',
|
||||||
|
parse: target => target.toLowerCase()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'amount',
|
||||||
|
prompt: 'How many units should be converted?',
|
||||||
|
type: 'float'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(msg, { base, target, amount }) {
|
||||||
|
try {
|
||||||
|
const value = math.unit(amount, base).to(target).toString();
|
||||||
|
return msg.say(value);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say('Either an invalid unit type was provided or the unit types do not match.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "66.8.1",
|
"version": "67.0.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user