Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { SlashCommandBuilder, EmbedBuilder} = require("discord.js");
- const Key = ""; //your bot token from topgg https://top.gg/bot/YourBotID/webhooks
- const BotID = "Your Bot ID";
- module.exports = {
- data: new SlashCommandBuilder()
- .setName("vote")
- .setDescription("Vote on top.gg")
- .setDMPermission(true),
- async execute(interaction, client) {
- const { user } = interaction;
- const response = await fetch(`https://top.gg/api/bots/${BotID}/check?userId=${user.id}`, {
- headers: {
- 'Authorization': Key
- }
- });
- const data = await response.json();
- const voteEmbed = new EmbedBuilder()
- .setColor("White")
- .setTitle("You voted for us!")
- .setDescription(`Thank you for voting for ${client.user.username}!`)
- .setFooter({ text: "Nexus Votes"});
- const embed = new EmbedBuilder()
- .setColor("White")
- .setTitle("Vote for us!")
- .setDescription(`Click [here](https://top.gg/bot/${BotID}/vote) to vote!`)
- .setFooter({ text: "Nexus Votes"});
- if (data.voted) {
- await interaction.reply({
- embeds: [voteEmbed]
- });
- } else {
- const reply = await interaction.reply({
- embeds: [embed]
- });
- const interval = setInterval(async () => {
- const response = await fetch(`https://top.gg/api/bots/${BotID}/check?userId=${user.id}`, {
- headers: {
- 'Authorization': Key
- }
- });
- const newData = await response.json();
- if (newData.voted) {
- clearInterval(interval);
- await reply.edit({
- embeds: [voteEmbed]
- });
- }
- }, 5000);
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment