feat(arabot): add logging for users using these commands to other users

This commit is contained in:
smyalygames 2023-03-07 15:10:18 +00:00
parent 60c4b8f0f3
commit 21a53a1a75
4 changed files with 42 additions and 26 deletions

View File

@ -20,6 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import { N1984 } from '#utils/gifs'; import { N1984 } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun';
export class N1984Command extends Command { export class N1984Command extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -46,9 +47,10 @@ export class N1984Command extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// Get the user // Get the user
// TODO exception handling const { user } = interaction;
const member = interaction.member!.user;
const memberGuildMember = interaction.guild!.members.cache.get(member.id)!; await addFunLog(user.id, '1984');
const count = await countTotal(user.id, '1984');
// Creates the embed for the 1984 reaction // Creates the embed for the 1984 reaction
// Add a 1 in 1000 chance of Dantas literally making ARA 1984 // 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)]; : N1984[Math.floor(Math.random() * N1984.length)];
const n1984Embed = new EmbedBuilder() const n1984Embed = new EmbedBuilder()
.setColor('#ffffff') .setColor('#ffffff')
.setTitle(`${memberGuildMember.displayName} is happy!`) .setTitle(`${user.username} is happy!`)
.setImage(random1984); .setImage(random1984)
.setFooter({ text: `${user.username}'s 1984 count: ${count}` });
// Send the embed // Send the embed
await interaction.reply({ embeds: [n1984Embed], fetchReply: true }); await interaction.reply({ embeds: [n1984Embed], fetchReply: true });

View File

@ -20,6 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import { Hugs } from '#utils/gifs'; import { Hugs } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun';
export class HugCommand extends Command { export class HugCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -48,19 +49,21 @@ export class HugCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// Get the users // Get the users
// TODO exception handling const user = interaction.options.getUser('user', true);
const user = interaction.options.getUser('user')!; const hugger = interaction.user;
const hugger = interaction.member!.user;
const huggerGuildMember = interaction.guild!.members.cache.get(hugger.id)!; await addFunLog(hugger.id, 'hug', user.id);
const count = await countTotal(hugger.id, 'hug', user.id);
// Creates the embed for the hug // Creates the embed for the hug
const randomHug = Hugs[Math.floor(Math.random() * Hugs.length)]; const randomHug = Hugs[Math.floor(Math.random() * Hugs.length)];
const hugEmbed = new EmbedBuilder() const hugEmbed = new EmbedBuilder()
.setColor('#0099ff') .setColor('#0099ff')
.setTitle(`Hug from ${huggerGuildMember.displayName}`) .setTitle(`Hug from ${hugger.username}`)
.setImage(randomHug); .setImage(randomHug)
.setFooter({ text: `Amount of hugs given from ${hugger.username} to you: ${count}` });
// Send the hug // Send the hug
await interaction.reply({ content: `<@${user.id}>`, embeds: [hugEmbed], fetchReply: true }); await interaction.reply({ content: `${user.id}`, embeds: [hugEmbed], fetchReply: true });
} }
} }

View File

@ -20,6 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import { Kill } from '#utils/gifs'; import { Kill } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun';
export class KillCommand extends Command { export class KillCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -48,19 +49,26 @@ export class KillCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// Get the users // Get the users
// TODO exception handling const user = interaction.options.getUser('user', true)!;
const user = interaction.options.getUser('user')!; const sender = interaction.user;
const killer = interaction.member!.user;
const killerGuildMember = interaction.guild!.members.cache.get(killer.id)!; 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 // Creates the embed for the kill
const randomKill = Kill[Math.floor(Math.random() * Kill.length)]; const randomKill = Kill[Math.floor(Math.random() * Kill.length)];
const killEmbed = new EmbedBuilder() const killEmbed = new EmbedBuilder()
.setColor('#ff0000') .setColor('#ff0000')
.setTitle(`Kill from ${killerGuildMember.displayName}`) .setTitle(`Kill from ${sender.username}`)
.setImage(randomKill); .setImage(randomKill)
.setFooter({ text: `Amount of kills from ${sender.username} to you: ${count}` });
// Send the kill // Send the kill
await interaction.reply({ content: `<@${user.id}>`, embeds: [killEmbed], fetchReply: true }); await interaction.reply({ content: `${user.id}`, embeds: [killEmbed], fetchReply: true });
} }
} }

View File

@ -20,6 +20,7 @@
import { Command, RegisterBehavior } from '@sapphire/framework'; import { Command, RegisterBehavior } from '@sapphire/framework';
import { EmbedBuilder } from 'discord.js'; import { EmbedBuilder } from 'discord.js';
import { Poke } from '#utils/gifs'; import { Poke } from '#utils/gifs';
import { addFunLog, countTotal } from '#utils/database/fun';
export class PokeCommand extends Command { export class PokeCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) { public constructor(context: Command.Context, options: Command.Options) {
@ -27,7 +28,6 @@ export class PokeCommand extends Command {
...options, ...options,
name: 'poke', name: 'poke',
description: 'Poke a user', description: 'Poke a user',
preconditions: [['CoordinatorOnly', 'PatreonOnly']],
}); });
} }
@ -49,17 +49,19 @@ export class PokeCommand extends Command {
// Command run // Command run
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) { public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// Get the users // Get the users
// TODO exception handling const user = interaction.options.getUser('user', true)!;
const user = interaction.options.getUser('user')!; const sender = interaction.user;
const poker = interaction.member!.user;
const pokerGuildMember = interaction.guild!.members.cache.get(poker.id)!; await addFunLog(sender.id, 'poke', user.id);
const count = await countTotal(sender.id, 'poke', user.id);
// Creates the embed for the poke // Creates the embed for the poke
const randomPoke = Poke[Math.floor(Math.random() * Poke.length)]; const randomPoke = Poke[Math.floor(Math.random() * Poke.length)];
const pokeEmbed = new EmbedBuilder() const pokeEmbed = new EmbedBuilder()
.setColor('#0099ff') .setColor('#0099ff')
.setTitle(`Poke from ${pokerGuildMember.displayName}`) .setTitle(`Poke from ${sender.username}`)
.setImage(randomPoke); .setImage(randomPoke)
.setFooter({ text: `Amount of pokes from ${sender.username} to you: ${count}` });
// Send the poke // Send the poke
await interaction.reply({ content: `<@${user.id}>`, embeds: [pokeEmbed], fetchReply: true }); await interaction.reply({ content: `<@${user.id}>`, embeds: [pokeEmbed], fetchReply: true });