admin管理员组文章数量:1403516
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 badges2 Answers
Reset to default 3It 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.
本文标签:
版权声明:本文标题:javascript - A discord bot activating another bot via commands or detect user who used a bot command - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744393927a2604120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论