Move few fun commands to interactions
This commit is contained in:
parent
533ce58647
commit
457de774ce
|
@ -1,6 +1,34 @@
|
|||
import {SlashCommandBuilder} from "@discordjs/builders";
|
||||
import {CommandInteraction} from "discord.js";
|
||||
import {Command, NamedCommand} from "onion-lasers";
|
||||
import {Random} from "../../lib";
|
||||
//Ravioli ravioli...
|
||||
//number from 1 to 9
|
||||
export const header = new SlashCommandBuilder()
|
||||
.setDescription("Ravioli ravioli...")
|
||||
.addIntegerOption((option) => option.setName("number").setDescription("Number from 1 to 9").setRequired(false));
|
||||
|
||||
export async function handler(interaction: CommandInteraction) {
|
||||
const {options} = interaction;
|
||||
try {
|
||||
//get the number from the options if it fails fallback to the randomizer
|
||||
var response = options.getInteger("number", true);
|
||||
} catch (e) {
|
||||
var response = Random.int(1, 10);
|
||||
}
|
||||
console.log(response);
|
||||
|
||||
interaction.reply({
|
||||
embeds: [
|
||||
{
|
||||
title: "Ravioli ravioli...",
|
||||
image: {
|
||||
url: `https://raw.githubusercontent.com/keanuplayz/TravBot/master/assets/ravi${response}.png`
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
export default new NamedCommand({
|
||||
description: "Ravioli ravioli...",
|
||||
usage: "[number from 1 to 9]",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {SlashCommandBuilder} from "@discordjs/builders";
|
||||
import {CommandInteraction} from "discord.js";
|
||||
import {NamedCommand, RestCommand} from "onion-lasers";
|
||||
|
||||
const letters: {[letter: string]: string[]} = {
|
||||
a: "aáàảãạâấầẩẫậăắằẳẵặ".split(""),
|
||||
e: "eéèẻẽẹêếềểễệ".split(""),
|
||||
|
@ -29,8 +30,22 @@ function transform(str: string) {
|
|||
return out;
|
||||
}
|
||||
|
||||
let phrase = "I have no currently set phrase!";
|
||||
export const header = new SlashCommandBuilder()
|
||||
.setDescription("Transforms your text into vietnamese.")
|
||||
.addStringOption((option) =>
|
||||
option.setName("text").setDescription("The text you want to transform").setRequired(true)
|
||||
);
|
||||
|
||||
export async function handler(interaction: CommandInteraction) {
|
||||
const {options} = interaction;
|
||||
const response = options.getString("text", true);
|
||||
|
||||
interaction.reply(transform(response));
|
||||
// You might notice the remove message code is missing here. It's because reactions collectors are
|
||||
//not a thing in interactions. The best alternative would buttons
|
||||
}
|
||||
|
||||
let phrase = "I have no currently set phrase!";
|
||||
export default new NamedCommand({
|
||||
description: "Transforms your text into vietnamese.",
|
||||
usage: "([text])",
|
||||
|
|
|
@ -1,7 +1,38 @@
|
|||
import {SlashCommandBuilder} from "@discordjs/builders";
|
||||
import {NamedCommand, RestCommand} from "onion-lasers";
|
||||
import {MessageEmbed} from "discord.js";
|
||||
import {MessageEmbed, CommandInteraction} from "discord.js";
|
||||
import urban from "relevant-urban";
|
||||
|
||||
export const header = new SlashCommandBuilder()
|
||||
.setDescription("Gives you a definition of the inputted word.")
|
||||
.addStringOption((option) =>
|
||||
option.setName("word").setDescription("The word you're looking for").setRequired(true)
|
||||
);
|
||||
|
||||
export async function handler(interaction: CommandInteraction) {
|
||||
const {options} = interaction;
|
||||
await interaction.reply("Working on it....");
|
||||
const response = options.getString("word", true);
|
||||
// [Bug Fix]: Use encodeURIComponent() when emojis are used: "TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters"
|
||||
urban(encodeURIComponent(response))
|
||||
.then(async (res) => {
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x1d2439)
|
||||
.setTitle(res.word)
|
||||
.setURL(res.urbanURL)
|
||||
.setDescription(`**Definition:**\n*${res.definition}*\n\n**Example:**\n*${res.example}*`)
|
||||
// [Bug Fix] When an embed field is empty (if the author field is missing, like the top entry for "british"): "RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty."
|
||||
.addField("Author", res.author || "N/A", true)
|
||||
.addField("Rating", `**\`Upvotes: ${res.thumbsUp} | Downvotes: ${res.thumbsDown}\`**`);
|
||||
if (res.tags && res.tags.length > 0 && res.tags.join(" ").length < 1024)
|
||||
embed.addField("Tags", res.tags.join(", "), true);
|
||||
interaction.editReply("Here you go!");
|
||||
await interaction.editReply({embeds: [embed]});
|
||||
})
|
||||
.catch(async () => {
|
||||
await interaction.editReply("Sorry, that word was not found.");
|
||||
});
|
||||
}
|
||||
export default new NamedCommand({
|
||||
description: "Gives you a definition of the inputted word.",
|
||||
run: "Please input a word.",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {SlashCommandBuilder} from "@discordjs/builders";
|
||||
import {CommandInteraction} from "discord.js";
|
||||
import {NamedCommand, RestCommand} from "onion-lasers";
|
||||
|
||||
const vaporwave = (() => {
|
||||
const map = new Map<string, string>();
|
||||
const vaporwave =
|
||||
|
@ -21,6 +22,17 @@ function getVaporwaveText(text: string): string {
|
|||
return output;
|
||||
}
|
||||
|
||||
export const header = new SlashCommandBuilder()
|
||||
.setDescription("Transforms your text into vaporwave.")
|
||||
.addStringOption((option) =>
|
||||
option.setName("text").setDescription("The text you want to vaporwave.").setRequired(true)
|
||||
);
|
||||
|
||||
export async function handler(interaction: CommandInteraction) {
|
||||
const {options} = interaction;
|
||||
const response = options.getString("text", true);
|
||||
await interaction.reply(getVaporwaveText(response));
|
||||
}
|
||||
export default new NamedCommand({
|
||||
description: "Transforms your text into vaporwave.",
|
||||
run: "You need to enter some text!",
|
||||
|
|
|
@ -1,7 +1,47 @@
|
|||
import {NamedCommand, RestCommand} from "onion-lasers";
|
||||
import {MessageEmbed} from "discord.js";
|
||||
import {SlashCommandBuilder} from "@discordjs/builders";
|
||||
import {MessageEmbed, CommandInteraction} from "discord.js";
|
||||
import {find} from "weather-js";
|
||||
|
||||
export const header = new SlashCommandBuilder()
|
||||
.setDescription("Shows weather info of specified location.")
|
||||
.addStringOption((option) =>
|
||||
option.setName("location").setDescription("The location you're looking for").setRequired(true)
|
||||
);
|
||||
|
||||
export async function handler(interaction: CommandInteraction) {
|
||||
const {options} = interaction;
|
||||
await interaction.reply("Working on it....");
|
||||
const response = options.getString("location", true);
|
||||
|
||||
find(
|
||||
{
|
||||
search: response,
|
||||
degreeType: "C"
|
||||
},
|
||||
async function (error, result) {
|
||||
if (error) return await interaction.editReply(error.toString());
|
||||
if (result.length === 0) return await interaction.editReply("No city found by that name.");
|
||||
var current = result[0].current;
|
||||
var location = result[0].location;
|
||||
const embed = new MessageEmbed()
|
||||
.setDescription(`**${current.skytext}**`)
|
||||
.setAuthor(`Weather for ${current.observationpoint}`)
|
||||
.setThumbnail(current.imageUrl)
|
||||
.setColor(0x00ae86)
|
||||
.addField("Timezone", `UTC${location.timezone}`, true)
|
||||
.addField("Degree Type", "C", true)
|
||||
.addField("Temperature", `${current.temperature} Degrees`, true)
|
||||
.addField("Feels like", `${current.feelslike} Degrees`, true)
|
||||
.addField("Winds", current.winddisplay, true)
|
||||
.addField("Humidity", `${current.humidity}%`, true);
|
||||
interaction.editReply("Here you go!"); // remove the working on message
|
||||
return await interaction.editReply({
|
||||
embeds: [embed]
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
export default new NamedCommand({
|
||||
description: "Shows weather info of specified location.",
|
||||
run: "You need to provide a city.",
|
||||
|
|
Loading…
Reference in New Issue