diff --git a/src/commands/fun/1984.ts b/src/commands/fun/1984.ts index 06089e4..b78571d 100644 --- a/src/commands/fun/1984.ts +++ b/src/commands/fun/1984.ts @@ -20,6 +20,7 @@ import { Command, RegisterBehavior } from '@sapphire/framework'; import { EmbedBuilder } from 'discord.js'; import { N1984 } from '#utils/gifs'; +import { addFunLog, countTotal } from '#utils/database/fun'; export class N1984Command extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -46,9 +47,10 @@ export class N1984Command 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 { user } = interaction; + + await addFunLog(user.id, '1984'); + const count = await countTotal(user.id, '1984'); // Creates the embed for the 1984 reaction // Add a 1 in 1000 chance of Dantas literally making ARA 1984 @@ -56,8 +58,9 @@ export class N1984Command extends Command { : N1984[Math.floor(Math.random() * N1984.length)]; const n1984Embed = new EmbedBuilder() .setColor('#ffffff') - .setTitle(`${memberGuildMember.displayName} is happy!`) - .setImage(random1984); + .setTitle(`${user.username} is happy!`) + .setImage(random1984) + .setFooter({ text: `${user.username}'s 1984 count: ${count}` }); // Send the embed await interaction.reply({ embeds: [n1984Embed], fetchReply: true }); diff --git a/src/commands/fun/hug.ts b/src/commands/fun/hug.ts index b8d6577..e173d08 100644 --- a/src/commands/fun/hug.ts +++ b/src/commands/fun/hug.ts @@ -20,6 +20,7 @@ import { Command, RegisterBehavior } from '@sapphire/framework'; import { EmbedBuilder } from 'discord.js'; import { Hugs } from '#utils/gifs'; +import { addFunLog, countTotal } from '#utils/database/fun'; export class HugCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -48,19 +49,21 @@ export class HugCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { // Get the users - // TODO exception handling - const user = interaction.options.getUser('user')!; - const hugger = interaction.member!.user; - const huggerGuildMember = interaction.guild!.members.cache.get(hugger.id)!; + const user = interaction.options.getUser('user', true); + const hugger = interaction.user; + + await addFunLog(hugger.id, 'hug', user.id); + const count = await countTotal(hugger.id, 'hug', user.id); // Creates the embed for the hug const randomHug = Hugs[Math.floor(Math.random() * Hugs.length)]; const hugEmbed = new EmbedBuilder() .setColor('#0099ff') - .setTitle(`Hug from ${huggerGuildMember.displayName}`) - .setImage(randomHug); + .setTitle(`Hug from ${hugger.username}`) + .setImage(randomHug) + .setFooter({ text: `Amount of hugs given from ${hugger.username} to you: ${count}` }); // Send the hug - await interaction.reply({ content: `<@${user.id}>`, embeds: [hugEmbed], fetchReply: true }); + await interaction.reply({ content: `${user.id}`, embeds: [hugEmbed], fetchReply: true }); } } diff --git a/src/commands/fun/kill.ts b/src/commands/fun/kill.ts index cfbd3b3..5105e8c 100644 --- a/src/commands/fun/kill.ts +++ b/src/commands/fun/kill.ts @@ -20,6 +20,7 @@ import { Command, RegisterBehavior } from '@sapphire/framework'; import { EmbedBuilder } from 'discord.js'; import { Kill } from '#utils/gifs'; +import { addFunLog, countTotal } from '#utils/database/fun'; export class KillCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -48,19 +49,26 @@ export class KillCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { // Get the users - // TODO exception handling - const user = interaction.options.getUser('user')!; - const killer = interaction.member!.user; - const killerGuildMember = interaction.guild!.members.cache.get(killer.id)!; + const user = interaction.options.getUser('user', true)!; + const sender = interaction.user; + + if (user.id === sender.id) { + await interaction.reply('You changed your mind'); + return; + } + + await addFunLog(sender.id, 'kill', user.id); + const count = await countTotal(sender.id, 'kill', user.id); // Creates the embed for the kill const randomKill = Kill[Math.floor(Math.random() * Kill.length)]; const killEmbed = new EmbedBuilder() .setColor('#ff0000') - .setTitle(`Kill from ${killerGuildMember.displayName}`) - .setImage(randomKill); + .setTitle(`Kill from ${sender.username}`) + .setImage(randomKill) + .setFooter({ text: `Amount of kills from ${sender.username} to you: ${count}` }); // Send the kill - await interaction.reply({ content: `<@${user.id}>`, embeds: [killEmbed], fetchReply: true }); + await interaction.reply({ content: `${user.id}`, embeds: [killEmbed], fetchReply: true }); } } diff --git a/src/commands/fun/poke.ts b/src/commands/fun/poke.ts index 02ccae5..b8b2927 100644 --- a/src/commands/fun/poke.ts +++ b/src/commands/fun/poke.ts @@ -20,6 +20,7 @@ import { Command, RegisterBehavior } from '@sapphire/framework'; import { EmbedBuilder } from 'discord.js'; import { Poke } from '#utils/gifs'; +import { addFunLog, countTotal } from '#utils/database/fun'; export class PokeCommand extends Command { public constructor(context: Command.Context, options: Command.Options) { @@ -27,7 +28,6 @@ export class PokeCommand extends Command { ...options, name: 'poke', description: 'Poke a user', - preconditions: [['CoordinatorOnly', 'PatreonOnly']], }); } @@ -49,17 +49,19 @@ export class PokeCommand extends Command { // Command run public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { // Get the users - // TODO exception handling - const user = interaction.options.getUser('user')!; - const poker = interaction.member!.user; - const pokerGuildMember = interaction.guild!.members.cache.get(poker.id)!; + const user = interaction.options.getUser('user', true)!; + const sender = interaction.user; + + await addFunLog(sender.id, 'poke', user.id); + const count = await countTotal(sender.id, 'poke', user.id); // Creates the embed for the poke const randomPoke = Poke[Math.floor(Math.random() * Poke.length)]; const pokeEmbed = new EmbedBuilder() .setColor('#0099ff') - .setTitle(`Poke from ${pokerGuildMember.displayName}`) - .setImage(randomPoke); + .setTitle(`Poke from ${sender.username}`) + .setImage(randomPoke) + .setFooter({ text: `Amount of pokes from ${sender.username} to you: ${count}` }); // Send the poke await interaction.reply({ content: `<@${user.id}>`, embeds: [pokeEmbed], fetchReply: true });