mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 13:54:12 +02:00
feat(arabot): add type checking and made footers for existing embeds better
This commit is contained in:
parent
7943a2d1b8
commit
5bbc5057fc
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { N1984 } from '#utils/gifs';
|
||||
import { addFunLog, countTotal } from '#utils/database/fun';
|
||||
|
||||
@ -45,10 +45,26 @@ export class N1984Command extends Command {
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the user
|
||||
const { user } = interaction;
|
||||
const { member } = interaction;
|
||||
|
||||
await addFunLog(user.id, '1984');
|
||||
const count = await countTotal(user.id, '1984');
|
||||
// Type checks
|
||||
if (!(member instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await addFunLog(member.id, '1984');
|
||||
const count = await countTotal(member.id, '1984');
|
||||
|
||||
let embedFooter: string;
|
||||
if (count === 1) {
|
||||
embedFooter = `${member.displayName} 1984'd the server for the first time!`;
|
||||
} else {
|
||||
embedFooter = `${member.displayName} 1984'd the server ${count} times!`;
|
||||
}
|
||||
|
||||
// Creates the embed for the 1984 reaction
|
||||
// Add a 1 in 1000 chance of Dantas literally making ARA 1984
|
||||
@ -58,9 +74,9 @@ export class N1984Command extends Command {
|
||||
: N1984[Math.floor(Math.random() * N1984.length)];
|
||||
const n1984Embed = new EmbedBuilder()
|
||||
.setColor('#ffffff')
|
||||
.setTitle(`${user.username} is happy!`)
|
||||
.setTitle(`${member.displayName} is happy!`)
|
||||
.setImage(random1984)
|
||||
.setFooter({ text: `${user.username}'s 1984 count: ${count}` });
|
||||
.setFooter({ text: embedFooter });
|
||||
|
||||
// Send the embed
|
||||
await interaction.reply({ embeds: [n1984Embed], fetchReply: true });
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Cringe } from '#utils/gifs';
|
||||
import { addFunLog, countTotal } from '#utils/database/fun';
|
||||
|
||||
@ -44,19 +44,34 @@ export class CringeCommand extends Command {
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the user
|
||||
// TODO exception handling
|
||||
const { user } = interaction;
|
||||
const { member } = interaction;
|
||||
|
||||
await addFunLog(user.id, 'cringe');
|
||||
const count = await countTotal(user.id, 'cringe');
|
||||
// Type check
|
||||
if (!(member instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await addFunLog(member.id, 'cringe');
|
||||
const count = await countTotal(member.id, 'cringe');
|
||||
|
||||
let embedFooter: string;
|
||||
if (count === 1) {
|
||||
embedFooter = `${member.displayName} cringed for the first time!`;
|
||||
} else {
|
||||
embedFooter = `${member.displayName} cringed ${count} times!`;
|
||||
}
|
||||
|
||||
// Creates the embed for the cringe reaction
|
||||
const randomCringe = Cringe[Math.floor(Math.random() * Cringe.length)];
|
||||
const cringeEmbed = new EmbedBuilder()
|
||||
.setColor('#001148')
|
||||
.setTitle(`${user.username} feels immense cringe...`)
|
||||
.setTitle(`${member.displayName} feels immense cringe...`)
|
||||
.setImage(randomCringe)
|
||||
.setFooter({ text: `${user.username}'s cringe count: ${count}` });
|
||||
.setFooter({ text: embedFooter });
|
||||
|
||||
// Send the embed
|
||||
await interaction.reply({ embeds: [cringeEmbed], fetchReply: true });
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Happy } from '#utils/gifs';
|
||||
|
||||
export class HappyCommand extends Command {
|
||||
@ -44,15 +44,22 @@ export class HappyCommand extends Command {
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the user
|
||||
// TODO exception handling
|
||||
const member = interaction.member!.user;
|
||||
const memberGuildMember = interaction.guild!.members.cache.get(member.id)!;
|
||||
const { member } = interaction;
|
||||
|
||||
// Type checks
|
||||
if (!(member instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Creates the embed for the happy reaction
|
||||
const randomHappy = Happy[Math.floor(Math.random() * Happy.length)];
|
||||
const happyEmbed = new EmbedBuilder()
|
||||
.setColor('#40ff00')
|
||||
.setTitle(`${memberGuildMember.displayName} is happy!`)
|
||||
.setTitle(`${member.displayName} is happy!`)
|
||||
.setImage(randomHappy);
|
||||
|
||||
// Send the embed
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Hugs } from '#utils/gifs';
|
||||
import { addFunLog, countTotal } from '#utils/database/fun';
|
||||
|
||||
@ -54,20 +54,43 @@ export class HugCommand extends Command {
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the users
|
||||
const user = interaction.options.getUser('user', true);
|
||||
const hugger = interaction.user;
|
||||
const hugger = interaction.member;
|
||||
|
||||
// Type Checks
|
||||
|
||||
if (!(hugger instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await addFunLog(hugger.id, 'hug', user.id);
|
||||
const count = await countTotal(hugger.id, 'hug', user.id);
|
||||
|
||||
let embedFooter: string;
|
||||
if (hugger.id === user.id) {
|
||||
if (count === 1) {
|
||||
embedFooter = `You hugged yourself for the first time!`;
|
||||
} else {
|
||||
embedFooter = `You hugged yourself ${count} times!`;
|
||||
}
|
||||
} else {
|
||||
if (count === 1) {
|
||||
embedFooter = `${hugger.displayName} hugged you for the first time!`;
|
||||
} else {
|
||||
embedFooter = `${hugger.displayName} hugged you ${count} times!`;
|
||||
}
|
||||
}
|
||||
|
||||
// Creates the embed for the hug
|
||||
const randomHug = Hugs[Math.floor(Math.random() * Hugs.length)];
|
||||
const hugEmbed = new EmbedBuilder()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(`Hug from ${hugger.username}`)
|
||||
.setTitle(`Hug from ${hugger.displayName}`)
|
||||
.setImage(randomHug)
|
||||
.setFooter({
|
||||
text: `Amount of hugs given from ${hugger.username} to you: ${count}`,
|
||||
});
|
||||
.setFooter({ text: embedFooter });
|
||||
|
||||
// Send the hug
|
||||
await interaction.reply({
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Kill } from '#utils/gifs';
|
||||
import { addFunLog, countTotal } from '#utils/database/fun';
|
||||
|
||||
@ -54,7 +54,16 @@ export class KillCommand extends Command {
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the users
|
||||
const user = interaction.options.getUser('user', true)!;
|
||||
const sender = interaction.user;
|
||||
const sender = interaction.member;
|
||||
|
||||
// Type checks
|
||||
if (!(sender instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.id === sender.id) {
|
||||
await interaction.reply('You changed your mind');
|
||||
@ -64,15 +73,20 @@ export class KillCommand extends Command {
|
||||
await addFunLog(sender.id, 'kill', user.id);
|
||||
const count = await countTotal(sender.id, 'kill', user.id);
|
||||
|
||||
let embedFooter: string;
|
||||
if (count === 1) {
|
||||
embedFooter = `${sender.displayName} killed you for the first time!`;
|
||||
} else {
|
||||
embedFooter = `${sender.displayName} killed you ${count} times!`;
|
||||
}
|
||||
|
||||
// Creates the embed for the kill
|
||||
const randomKill = Kill[Math.floor(Math.random() * Kill.length)];
|
||||
const killEmbed = new EmbedBuilder()
|
||||
.setColor('#ff0000')
|
||||
.setTitle(`Kill from ${sender.username}`)
|
||||
.setTitle(`Kill from ${sender.displayName}`)
|
||||
.setImage(randomKill)
|
||||
.setFooter({
|
||||
text: `Amount of kills from ${sender.username} to you: ${count}`,
|
||||
});
|
||||
.setFooter({ text: embedFooter });
|
||||
|
||||
// Send the kill
|
||||
await interaction.reply({
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Poke } from '#utils/gifs';
|
||||
import { addFunLog, countTotal } from '#utils/database/fun';
|
||||
|
||||
@ -54,20 +54,42 @@ export class PokeCommand extends Command {
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the users
|
||||
const user = interaction.options.getUser('user', true)!;
|
||||
const sender = interaction.user;
|
||||
const sender = interaction.member;
|
||||
|
||||
// Type checks
|
||||
if (!(sender instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await addFunLog(sender.id, 'poke', user.id);
|
||||
const count = await countTotal(sender.id, 'poke', user.id);
|
||||
|
||||
let embedFooter: string;
|
||||
if (sender.id === user.id) {
|
||||
if (count === 1) {
|
||||
embedFooter = `You poked yourself for the first time!`;
|
||||
} else {
|
||||
embedFooter = `You poked yourself ${count} times!`;
|
||||
}
|
||||
} else {
|
||||
if (count === 1) {
|
||||
embedFooter = `${sender.displayName} poked you for the first time!`;
|
||||
} else {
|
||||
embedFooter = `${sender.displayName} poked you ${count} times!`;
|
||||
}
|
||||
}
|
||||
|
||||
// Creates the embed for the poke
|
||||
const randomPoke = Poke[Math.floor(Math.random() * Poke.length)];
|
||||
const pokeEmbed = new EmbedBuilder()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(`Poke from ${sender.username}`)
|
||||
.setTitle(`Poke from ${sender.displayName}`)
|
||||
.setImage(randomPoke)
|
||||
.setFooter({
|
||||
text: `Amount of pokes from ${sender.username} to you: ${count}`,
|
||||
});
|
||||
.setFooter({ text: embedFooter });
|
||||
|
||||
// Send the poke
|
||||
await interaction.reply({
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Sad } from '#utils/gifs';
|
||||
|
||||
export class SadCommand extends Command {
|
||||
@ -44,15 +44,22 @@ export class SadCommand extends Command {
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the user
|
||||
// TODO exception handling
|
||||
const member = interaction.member!.user;
|
||||
const memberGuildMember = interaction.guild!.members.cache.get(member.id)!;
|
||||
const { member } = interaction;
|
||||
|
||||
// Type checks
|
||||
if (!(member instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Creates the embed for the sad reaction
|
||||
const randomSad = Sad[Math.floor(Math.random() * Sad.length)];
|
||||
const sadEmbed = new EmbedBuilder()
|
||||
.setColor('#001148')
|
||||
.setTitle(`${memberGuildMember.displayName} is sad...`)
|
||||
.setTitle(`${member.displayName} is sad...`)
|
||||
.setImage(randomSad);
|
||||
|
||||
// Send the embed
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import { Command, RegisterBehavior } from '@sapphire/framework';
|
||||
import { EmbedBuilder } from 'discord.js';
|
||||
import { EmbedBuilder, GuildMember } from 'discord.js';
|
||||
import { Shrug } from '#utils/gifs';
|
||||
|
||||
export class ShrugCommand extends Command {
|
||||
@ -44,15 +44,22 @@ export class ShrugCommand extends Command {
|
||||
// Command run
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
// Get the user
|
||||
// TODO exception handling
|
||||
const member = interaction.member!.user;
|
||||
const memberGuildMember = interaction.guild!.members.cache.get(member.id)!;
|
||||
const { member } = interaction;
|
||||
|
||||
// Type checks
|
||||
if (!(member instanceof GuildMember)) {
|
||||
await interaction.reply({
|
||||
ephemeral: true,
|
||||
content: 'Failed to fetch your user on the bot!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Creates the embed for the shrug reaction
|
||||
const randomShrug = Shrug[Math.floor(Math.random() * Shrug.length)];
|
||||
const shrugEmbed = new EmbedBuilder()
|
||||
.setColor('#001980')
|
||||
.setTitle(`${memberGuildMember.displayName} shrugs`)
|
||||
.setTitle(`${member.displayName} shrugs`)
|
||||
.setImage(randomShrug);
|
||||
|
||||
// Send the embed
|
||||
|
Loading…
x
Reference in New Issue
Block a user