From d9264c90efb0600bb59fc15a698ca600206c9e37 Mon Sep 17 00:00:00 2001 From: a456pur Date: Fri, 2 Feb 2024 18:49:35 +1000 Subject: [PATCH] totally needed important changes --- commands/fun/dice.js | 22 ++++++++++++++++++++++ index.js | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 commands/fun/dice.js diff --git a/commands/fun/dice.js b/commands/fun/dice.js new file mode 100644 index 0000000..95400fd --- /dev/null +++ b/commands/fun/dice.js @@ -0,0 +1,22 @@ +const { EmbedBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("roll") + .setDescription("Roll a 6-sided dice!"), + async execute(interaction) { + try { + const result = Math.floor(Math.random() * 6) + 1; + + let rollEmbed = new EmbedBuilder() + .setTitle(`🎲 **${result}**`) + .setColor("#0099ff") + + await interaction.reply({ embeds: [rollEmbed] }); + } catch (error) { + console.error(error); + await interaction.reply("There was an error. Please ping the owner if you see this."); + } + }, +}; diff --git a/index.js b/index.js index 9c04e86..673a660 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const fs = require("node:fs"); const path = require("node:path"); -const { Client, Collection, GatewayIntentBits, Events } = require("discord.js"); +const { Client, Collection, GatewayIntentBits, Events, EmbedBuilder } = require("discord.js"); const { token, widgets, logs_channel, links, dispenser_logs } = require("./config.json"); const client = new Client({ intents: ["Guilds", "GuildMessages", "GuildMembers", "MessageContent"], allowedMentions: { everyone: [false], roles: [false] } }); const Sequelize = require("sequelize"); @@ -101,14 +101,44 @@ for (const file of eventFiles) { client.login(token); -client.on("messageDelete", (interaction) => { +client.on("messageDelete", (message) => { const logsChannel = client.channels.cache.get(logs_channel.toString()); - logsChannel.send(`Message deleted from ${interaction.author.tag}: ${interaction.content}`); + + const delEmbed = new EmbedBuilder() + delEmbed.setColor("#db3c30") + delEmbed.setTitle("🗑️ message deleted") + delEmbed.setDescription( + `> **author:** <@${message.author.id}> \n> **channel:** <#${message.channel.id}> \n> **timestamp:** ` + ); + + if (message.content) { + delEmbed.addFields({name: 'message:', value: message.content}); + } + + // extra thing here to check if message has attachments + if (message.attachments.size > 0) { + const attachments = message.attachments.map((attachment) => attachment.url); + delEmbed.addFields({name: "attached:", value: attachments.join("\n")}); + } + + logsChannel.send({ embeds: [delEmbed] }); }); client.on("messageUpdate", (oldm, newm) => { const logsChannel = client.channels.cache.get(logs_channel.toString()); - if (!oldm == newm) { - logsChannel.send(`Message edited from ${oldm.author.tag}: ${oldm} - ${newm}`); + if (oldm !== newm) { + const ediEmbed = new EmbedBuilder() + ediEmbed.setColor("#e2e833") + ediEmbed.setTitle("✍️ message edited") + ediEmbed.setDescription( + `> **author:** <@${oldm.author.id}> \n> **channel:** <#${oldm.channel.id}> \n> **timestamp:** ` + ); + + ediEmbed.addFields( + {name: 'before:', value: `${oldm}`, inline: true}, + {name: 'after:', value: `${newm}`, inline: true}, + ); + + logsChannel.send({ embeds: [ediEmbed] }); } }); client.on("interactionCreate", async (interaction) => {