Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-37/add a wave command #65

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .env.example

This file was deleted.

74 changes: 74 additions & 0 deletions src/commands/fun/wave.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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 { Wave } from "../../utils/gifs";

class WaveCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, {
...options,
name: "wave",
description: "Wave to a user",
preconditions: [["CoordinatorOnly", "PatreonOnly"]],
});
}

// Registers that this is a slash command
public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(
Fixed Show fixed Hide fixed
(builder) => builder
.setName(this.name)
.setDescription(this.description)
.addUserOption((option) =>
option
.setName("user")
.setDescription("User you want to wave to")
.setRequired(true)
),
{ behaviorWhenNotIdentical: RegisterBehavior.Overwrite }
);
}

// Command run
public async chatInputRun(interaction: Command.ChatInputInteraction) {
// Get the users
// TODO exception handling
const user = interaction.options.getUser("user")!;
const waver = interaction.member!.user;
const waverGuildMember = interaction.guild!.members.cache.get(waver.id)!;

// Creates the embed for the wave
const randomWave = Wave[Math.floor(Math.random() * Wave.length)];
const waveEmbed = new MessageEmbed()
.setColor("#0099ff")
.setTitle(`${waverGuildMember.displayName} waves at you, hello!`)
.setImage(randomWave);

// Send the wave
await interaction.reply({
content: `<@${user.id}>`,
embeds: [waveEmbed],
fetchReply: true,
});
}
}

export default WaveCommand;
9 changes: 9 additions & 0 deletions src/utils/gifs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ export const N1984 = [
'https://c.tenor.com/dcxOO-080OcAAAAd/discord-moderators.gif',
'https://c.tenor.com/-cUS-fPIEBsAAAAd/5second-slow-mode-1984.gif',
];

export const Wave = [
'https://c.tenor.com/Og0XNCa_vo8AAAAi/qoobee-hi.gif',
'https://c.tenor.com/DcDYpWonGbIAAAAi/budding-pop-cute.gif',
'https://c.tenor.com/PBG8IAgoXvQAAAAi/hello-waving-frog.gif',
'https://c.tenor.com/q2d-2wQ4qxQAAAAC/hello.gif',
'https://c.tenor.com/pqqlX7Ha8PcAAAAC/hello-bob.gif',
'https://c.tenor.com/_CA1LzW9opoAAAAi/wumpus-wumpuswave.gif',
];