mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 01:14:16 +02:00
feat(arabot): add happy and sad reactions
This commit is contained in:
parent
5f34ab2e93
commit
cc62db5016
63
src/commands/fun/happy.ts
Normal file
63
src/commands/fun/happy.ts
Normal file
@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
/*
|
||||
Animal Rights Advocates Discord Bot
|
||||
Copyright (C) 2022 Anthony Berg
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import { Happy } from '../../utils/gifs';
|
||||
|
||||
export class HappyCommand extends Command {
|
||||
public constructor(context: Command.Context, options: Command.Options) {
|
||||
super(context, {
|
||||
...options,
|
||||
name: 'happy',
|
||||
description: 'Express your happiness',
|
||||
preconditions: ['PatreonOnly'],
|
||||
});
|
||||
}
|
||||
|
||||
// Registers that this is a slash command
|
||||
public override registerApplicationCommands(registry: Command.Registry) {
|
||||
registry.registerChatInputCommand(
|
||||
(builder) => builder
|
||||
.setName(this.name)
|
||||
.setDescription(this.description),
|
||||
{
|
||||
behaviorWhenNotIdentical: RegisterBehavior.Overwrite,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputInteraction) {
|
||||
// Get the user
|
||||
// TODO exception handling
|
||||
const member = interaction.member!.user;
|
||||
const memberGuildMember = interaction.guild!.members.cache.get(member.id)!;
|
||||
|
||||
// Creates the embed for the happy reaction
|
||||
const randomHappy = Happy[Math.floor(Math.random() * Happy.length)];
|
||||
const happyEmbed = new MessageEmbed()
|
||||
.setColor('#40ff00')
|
||||
.setTitle(`Poke from ${memberGuildMember.displayName}`)
|
||||
.setImage(randomHappy);
|
||||
|
||||
// Send the embed
|
||||
await interaction.reply({ embeds: [happyEmbed], fetchReply: true });
|
||||
}
|
||||
}
|
63
src/commands/fun/sad.ts
Normal file
63
src/commands/fun/sad.ts
Normal file
@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
/*
|
||||
Animal Rights Advocates Discord Bot
|
||||
Copyright (C) 2022 Anthony Berg
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { MessageEmbed } from 'discord.js';
|
||||
import { Sad } from '../../utils/gifs';
|
||||
|
||||
export class SadCommand extends Command {
|
||||
public constructor(context: Command.Context, options: Command.Options) {
|
||||
super(context, {
|
||||
...options,
|
||||
name: 'sad',
|
||||
description: 'Express your sadness',
|
||||
preconditions: ['PatreonOnly'],
|
||||
});
|
||||
}
|
||||
|
||||
// Registers that this is a slash command
|
||||
public override registerApplicationCommands(registry: Command.Registry) {
|
||||
registry.registerChatInputCommand(
|
||||
(builder) => builder
|
||||
.setName(this.name)
|
||||
.setDescription(this.description),
|
||||
{
|
||||
behaviorWhenNotIdentical: RegisterBehavior.Overwrite,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputInteraction) {
|
||||
// Get the user
|
||||
// TODO exception handling
|
||||
const member = interaction.member!.user;
|
||||
const memberGuildMember = interaction.guild!.members.cache.get(member.id)!;
|
||||
|
||||
// Creates the embed for the sad reaction
|
||||
const randomSad = Sad[Math.floor(Math.random() * Sad.length)];
|
||||
const sadEmbed = new MessageEmbed()
|
||||
.setColor('#001148')
|
||||
.setTitle(`Poke from ${memberGuildMember.displayName}`)
|
||||
.setImage(randomSad);
|
||||
|
||||
// Send the embed
|
||||
await interaction.reply({ embeds: [sadEmbed], fetchReply: true });
|
||||
}
|
||||
}
|
@ -38,3 +38,21 @@ export const Poke = [
|
||||
'https://c.tenor.com/XAXSLU_w_yoAAAAd/boop-crow.gif',
|
||||
'https://c.tenor.com/o9X9XXVCm-MAAAAC/bird-cute.gif', // Thanks to Jonquil (277429709711605761) <3
|
||||
];
|
||||
|
||||
// Thanks Dantas (605924328004911133) for the gifs <3
|
||||
export const Happy = [
|
||||
'https://c.tenor.com/_4xCiEhhoZsAAAAd/dog-smile.gif',
|
||||
'https://c.tenor.com/GEP7e6U2uqgAAAAC/spongebob-happy.gif',
|
||||
'https://c.tenor.com/tNhtH9x3WZEAAAAC/swing-dance-swing-your-hips.gif',
|
||||
'https://c.tenor.com/C_Dl5-KCvVoAAAAC/friends-matthew-perry.gif',
|
||||
'https://c.tenor.com/aKFaZBrZFYcAAAAC/excited-spin.gif',
|
||||
];
|
||||
|
||||
// Thanks Dantas (605924328004911133) for the gifs <3
|
||||
export const Sad = [
|
||||
'https://c.tenor.com/6CujUsC1CIkAAAAd/crying-black-guy-meme50fps-interpolated-interpolated.gif',
|
||||
'https://c.tenor.com/RJnvTxShQGIAAAAC/disney-plus-disney.gif',
|
||||
'https://c.tenor.com/_XLEzC52ATQAAAAC/sad-walk.gif',
|
||||
'https://c.tenor.com/rD4KDir7lO0AAAAC/sad-pikachu.gif',
|
||||
'https://c.tenor.com/IeiDwBPDrZYAAAAC/peach-cat.gif',
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user