javascript - A discord bot activating another bot via commands or detect user who used a bot command - Stack Overflow

Ok, so Im trying to do the following rn:Im using the Disboard bot and beforehand rewarded users for bu

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 mand was "!d bump", so I could just make my bot to also react on it. They now changed to / mands, so my bot isnt reacting to it anymore.

So I see two possibilities. I either make a mand 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 mand and go on from there.

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

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 mand was "!d bump", so I could just make my bot to also react on it. They now changed to / mands, so my bot isnt reacting to it anymore.

So I see two possibilities. I either make a mand 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 mand and go on from there.

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

Share Improve this question asked Apr 24, 2022 at 12:23 yuskanyuskan 611 silver badge7 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

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

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

    message.interaction.mandName

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

If you want to check for a certain mand then you can check message.interaction.mandName and if you only want to listen to mands from a certain bot then you can just check the message.author.id.

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.mandName == "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 mand /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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744393928a4572045.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信