Skip to content

Commit

Permalink
Add vote logs channel and send vote logs message in incrementVote fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
chimpdev committed Mar 28, 2024
1 parent b4510c7 commit 7eb9c07
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ serverCategories:
- 'Other'
emojiMaxCategoriesLength: 4
emojiQueueChannelId: '1210805683751223377'
reviewQueueChannelId: '1213842162828054538'
reviewQueueChannelId: '1213842162828054538'
voteLogsChannelId: '1222817883470434304'
19 changes: 19 additions & 0 deletions server/src/utils/servers/incrementVote.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Server = require('@/schemas/Server');
const VoteTimeout = require('@/schemas/Server/Vote/Timeout');
const Premium = require('@/schemas/Premium');
const Discord = require('discord.js');

async function incrementVote(guildId, userId) {
const guild = client.guilds.cache.get(guildId);
Expand Down Expand Up @@ -70,6 +71,24 @@ async function incrementVote(guildId, userId) {
}
}).save();

const user = client.users.cache.get(userId) || await client.users.fetch(userId);
const embed = new Discord.EmbedBuilder()
.setColor(Discord.Colors.Purple)
.setAuthor({ name: guild.name + ' has received a vote!', iconURL: guild.iconURL() })
.setFields([
{
name: 'Given by',
value: `@${user.tag} (${user.id})`,
},
{
name: 'Total votes',
value: server.votes + incrementCount
}
])
.setFooter({ text: `Voted at ${new Date().toLocaleString()}` });

client.channels.cache.get(config.voteLogsChannelId).send({ embeds: [embed] });

return true;
}

Expand Down

0 comments on commit 7eb9c07

Please sign in to comment.