Git Product home page Git Product logo

Comments (9)

TecEash1 avatar TecEash1 commented on September 27, 2024

that’s an issue on your side and with your commands. I would suggest debugging the issues with logging statements. Not sure how I can help with that issue otherwise…

from taurus.

S1mp1yDucky avatar S1mp1yDucky commented on September 27, 2024

This is what i did, it should work normally

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const fs = require("fs");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("addpremium")
        .setDescription("Give premium to a user.")
        .addUserOption((option) =>
            option.setName("user").setDescription("The user to give premium.").setRequired(true),
        ),

    async execute(interaction) {
        if (interaction.user.id !== 'OWNER_ID') {
            const ownerOnlyEmbed = new EmbedBuilder()
                .setDescription(":x: This command is for the bot owner only.")
                .setColor("#FF0000"); // Red color for errors
            return interaction.reply({ embeds: [ownerOnlyEmbed] });
        }
        const userId = interaction.options.getUser("user").id;
        const premiumUsers = JSON.parse(fs.readFileSync("premium_users.json"));

        if (premiumUsers.includes(userId)) {
            const alreadyPremiumEmbed = new EmbedBuilder()
                .setDescription(`<@${userId}> is already a premium user.`)
                .setColor("#FF0000"); // Red color for errors
            return interaction.reply({ embeds: [alreadyPremiumEmbed] });
        }

        premiumUsers.push(userId);
        fs.writeFileSync("premium_users.json", JSON.stringify(premiumUsers));

        const successEmbed = new EmbedBuilder()
            .setDescription(`:white_check_mark: Premium status has been added to <@${userId}> successfully.`)
            .setColor("#00FF00"); // Green color for success
        await interaction.reply({ embeds: [successEmbed] });
    },
};

from taurus.

S1mp1yDucky avatar S1mp1yDucky commented on September 27, 2024

Whatever command i make just does not work.

from taurus.

TecEash1 avatar TecEash1 commented on September 27, 2024

I am not sure, at some point, your code is not working. You can debug this with the logging statements. Custom commands do work, you can test this by creating a new command in the slash commands directory and then make it so that the bot sends a simple message when it’s executed.

from taurus.

S1mp1yDucky avatar S1mp1yDucky commented on September 27, 2024

okay trying

from taurus.

S1mp1yDucky avatar S1mp1yDucky commented on September 27, 2024

that works

from taurus.

S1mp1yDucky avatar S1mp1yDucky commented on September 27, 2024

what about the code above? why is it not working

from taurus.

S1mp1yDucky avatar S1mp1yDucky commented on September 27, 2024

i made it work. im stupid

from taurus.

TecEash1 avatar TecEash1 commented on September 27, 2024

glad you managed to fix the issue!

from taurus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.