'A discord bot activating another bot via /commands or detect user who used a bot command

Ok, so Im trying to do the following rn: Im using the Disboard bot and beforehand rewarded users for bumping. That wasnt a problem, because the command was "!d bump", so I could just make my bot to also react on it. They now changed to / commands, so my bot isnt reacting to it anymore. How it is now

So I see two possibilities. I either make a command and than (if thats possible) my bot bumps instead of the user and the user just activates my bot. Or I detect the Bot message and (if thats possible) who used the command and go on from there.

Thanks for help and ideas, and have a great day!



Solution 1:[1]

It is not possible for bots to use other bots' slash commands; however, you can detect when someone uses a command for a certain bot. I will use discord.js v13 in my answer.

client.on("messageCreate", (message) => {
    // check if the message is a slash command
    if (message.type !== "APPLICATION_COMMAND") return;

    message.interaction.commandName

    // if so then you can access the user who triggered the command with
    message.interaction.user;
});

If you want to check for a certain command then you can check message.interaction.commandName and if you only want to listen to commands from a certain bot then you can just check the message.author.id.

Solution 2:[2]

I've been working on this for quite a bit, but here is how I made it:

if (message.type == "APPLICATION_COMMAND" && message.channel.id == "971729505708290099" && message.interaction.commandName == "bump") {
    message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
        VIEW_CHANNEL: false
    })
    setTimeout(function () {
        message.channel.permissionOverwrites.edit(message.guild.roles.everyone, {
            VIEW_CHANNEL: true
        })
    }, 7200000);
}

in this code when someone uses the slash command /bump, it hides the channel and then unhides it after 2 hours. Hope that helps :)

(This code is inside the client.on("messageCreate", (message) =>{})

Instead of hiding channels/showing them you can also just ping a certain role if you want.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 IRONM00N
Solution 2 Gleyveon