Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
KIO2gamer committed Feb 23, 2024
2 parents 4349da2 + 98e666b commit c981eb9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
55 changes: 55 additions & 0 deletions events/StarBoard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { Events, EmbedBuilder } = require("discord.js");

module.exports = {
name: Events.MessageReactionAdd,
async execute(reaction) {
// Your code here
// get channel id
// const
const channelId = reaction.client.db.get(
`starboard_${reaction.message.guild.id}`,
);
const channel = reaction.message.guild.channels.cache.get(channelId);
if (!channel) return;

const messageId = reaction.client.db.get(
`starboard_${reaction.message.guild.id}_${reaction.message.id}`,
);
const message = await channel.messages.fetch(messageId).catch(() => null);
if (message) {
const starboardMessage = await message.embeds[0];
if (starboardMessage) {
const starboardMessageId = starboardMessage.footer.text.split(" ")[2];
const starboardMessageFetch = await channel.messages
.fetch(starboardMessageId)
.catch(() => null);
if (starboardMessageFetch) {
starboardMessageFetch.edit({
embeds: [starboardMessage.setFooter(`⭐ ${reaction.count}`)],
});
}
}
}
else {
// make an embed
const embed = EmbedBuilder();
embed.setAuthor(
reaction.message.author.tag,
reaction.message.author.displayAvatarURL(),
);
embed.setDescription(reaction.message.content);
embed.setFooter(`⭐ ${reaction.count}`);
embed.setTimestamp();
embed.setColor("YELLOW");
if (reaction.message.attachments.size > 0) {
embed.setImage(reaction.message.attachments.first().url);
}

const starboardMessage = await channel.send({ embeds: [embed] });
reaction.client.db.set(
`starboard_${reaction.message.guild.id}_${reaction.message.id}`,
starboardMessage.id,
);
}
},
};
14 changes: 7 additions & 7 deletions commands/misc/tickets.js → old_cmds/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ module.exports = {
const user = interaction.options.getUser("user");
const role = interaction.options.getRole("role");
const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[43].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[43].value}`,
);
const logChannel = interaction.guild.channels.cache.get(logChannelId);

Expand Down Expand Up @@ -1151,7 +1151,7 @@ module.exports = {
claimUser: interaction.user.id,
});
const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[43].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[43].value}`,
);
const logsChannel =
interaction.guild.channels.cache.get(logChannelId);
Expand Down Expand Up @@ -1260,7 +1260,7 @@ module.exports = {
// }

const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[44].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[44].value}`,
);
const logsChannel = interaction.guild.channels.cache.get(logChannelId);
await logsChannel.send({ embeds: [logEmbed], files: [attachment] });
Expand Down Expand Up @@ -1672,7 +1672,7 @@ module.exports = {
const newName = interaction.options.getString("name");
interaction.channel.setName(`${newName}`);
const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[43].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[43].value}`,
);
const logChannel = interaction.guild.channels.cache.get(logChannelId);

Expand Down Expand Up @@ -1786,7 +1786,7 @@ module.exports = {
});

const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[43].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[43].value}`,
);
const logsChannel = interaction.guild.channels.cache.get(logChannelId);
if (logsChannel) await logsChannel.send({ embeds: [logEmbed] });
Expand Down Expand Up @@ -1939,7 +1939,7 @@ module.exports = {
}

const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[43].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[43].value}`,
);
const logChannel = interaction.guild.channels.cache.get(logChannelId);

Expand Down Expand Up @@ -2101,7 +2101,7 @@ module.exports = {
});

const logChannelId = interaction.client.db.get(
`logchannel_${interaction.guild.id}_${require("../../src/static/logTypes.json")[43].value}`,
`logchannel_${interaction.guild.id}_${require("../src/static/logTypes.json")[43].value}`,
);
const logsChannel =
interaction.guild.channels.cache.get(logChannelId);
Expand Down

0 comments on commit c981eb9

Please sign in to comment.