Move even more fun commands into interactions api

This commit is contained in:
smartfridge 2021-12-11 18:12:41 +01:00
parent a8cc1b4dad
commit 7482f193e2
4 changed files with 50 additions and 1 deletions

View File

@ -1,5 +1,13 @@
import {SlashCommandBuilder} from "@discordjs/builders";
import {CommandInteraction} from "discord.js";
import {NamedCommand, CHANNEL_TYPE} from "onion-lasers";
export const header = new SlashCommandBuilder().setDescription("Chooses someone to love.");
export async function handler(interaction: CommandInteraction) {
const member = interaction.guild!.members.cache.random();
if (!member) return interaction.reply("For some reason, an error occurred fetching a member.");
return interaction.reply(`I love ${member.nickname ?? member.user.username}!`);
}
export default new NamedCommand({
description: "Chooses someone to love.",
channelType: CHANNEL_TYPE.GUILD,

View File

@ -1,3 +1,5 @@
import {SlashCommandBuilder} from "@discordjs/builders";
import {CommandInteraction} from "discord.js";
import {NamedCommand} from "onion-lasers";
import {random} from "../../lib";
@ -58,7 +60,10 @@ const responses = [
"cat",
"large man"
];
export const header = new SlashCommandBuilder().setDescription("Sends random ok message.");
export async function handler(interaction: CommandInteraction) {
interaction.reply(`ok ${random(responses)}`);
}
export default new NamedCommand({
description: "Sends random ok message.",
async run({send}) {

View File

@ -1,6 +1,25 @@
import {NamedCommand, RestCommand} from "onion-lasers";
import {random} from "../../lib";
import {SlashCommandBuilder} from "@discordjs/builders";
import {CommandInteraction} from "discord.js";
export const header = new SlashCommandBuilder()
.setDescription("OwO-ifies the input.")
.addStringOption((option) => option.setName("text").setDescription("Text to owoify").setRequired(true));
export async function handler(interaction: CommandInteraction) {
const {options} = interaction;
const faces = ["owo", "UwU", ">w<", "^w^"];
const owoified = options
.getString("text", true)
.replace(/[rl]/g, "w")
.replace(/[RL]/g, "W")
.replace(/ove/g, "uv")
.replace(/n/g, "ny")
.replace(/N/g, "NY")
.replace(/\!/g, ` ${random(faces)} `);
interaction.reply(owoified);
}
export default new NamedCommand({
description: "OwO-ifies the input.",
run: "You need to specify some text to owoify.",

View File

@ -1,6 +1,23 @@
import {MessageAttachment, User} from "discord.js";
import {NamedCommand, Command, RestCommand, getUserByNickname} from "onion-lasers";
import petPetGif from "pet-pet-gif";
import {SlashCommandBuilder} from "@discordjs/builders";
import {CommandInteraction} from "discord.js";
//Ravioli ravioli...
//number from 1 to 9
export const header = new SlashCommandBuilder()
.setDescription("Generates a pat GIF of the avatar of the mentioned user.")
.addUserOption((option) => option.setName("user").setDescription("User you want a pat gif of.").setRequired(true));
export async function handler(interaction: CommandInteraction) {
await interaction.reply("Generating pat gif...");
const {options} = interaction;
const pfp = options.getUser("user", true).displayAvatarURL({format: "png"});
const gif = await petPetGif(pfp);
const file = new MessageAttachment(gif, "pat.gif");
await interaction.editReply({content: "Here you go!", files: [file]});
}
export default new NamedCommand({
description: "Generates a pat GIF of the provided attachment image OR the avatar of the mentioned user.",