Skip to content

Commit

Permalink
Merge pull request #2 from a456pur/main
Browse files Browse the repository at this point in the history
small changes
  • Loading branch information
skysthelimitt authored Feb 5, 2024
2 parents 2b2581d + d9264c9 commit f7a5dc0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
22 changes: 22 additions & 0 deletions commands/fun/dice.js
Original file line number Diff line number Diff line change
@@ -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.");
}
},
};
40 changes: 35 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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:** <t:${Math.floor(Date.now() / 1000)}:R> `
);

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:** <t:${Math.floor(Date.now() / 1000)}:R> `
);

ediEmbed.addFields(
{name: 'before:', value: `${oldm}`, inline: true},
{name: 'after:', value: `${newm}`, inline: true},
);

logsChannel.send({ embeds: [ediEmbed] });
}
});
client.on("interactionCreate", async (interaction) => {
Expand Down

0 comments on commit f7a5dc0

Please sign in to comment.