【问题标题】:How can I kick a certain user after someone typed a specific message有人键入特定消息后如何踢某个用户
【发布时间】:2020-10-10 06:22:39
【问题描述】:
bot.on ('message', message =>{

   if (message.content === ("test")) {

    message.guild.members.get("their id").kick(); //ive seen this online but i
                                                  //dont know how to set up this guild thing

因此,当有人键入测试时,应该踢出特定用户

【问题讨论】:

  • wdym你不知道怎么设置“这个公会的东西”?
  • 我不知道,但该命令不起作用,似乎我错过了一些关于它的内容
  • 显示错误,可能是你没有把“their id”换成id。
  • message.guild.members.get(Id).kick(); ^ TypeError: message.guild.members.get is not a function (而不是 id 我输入了实际的 id 所以用户的数量

标签: javascript bots discord discord.js


【解决方案1】:

Giuliopime 我不知道为什么我不能再发表评论了。只是想对您的帮助表示感谢!

【讨论】:

    【解决方案2】:

    要踢出特定成员,您需要从 guild.members.cache 中获取他。

    所以:

    if(message.content === 'test' && message.channel.type === 'text'){
       message.guild.members.cache.get('ID of the member to kick').kick();
    }
    

    message.channel.type === 'text' 用于防止机器人在收到 DM 中的“测试”消息时崩溃,因为如果它在 DM 中收到它,它就无法获得message.guild。 希望这会有所帮助。

    【讨论】:

    • 我不想踢出输入消息的用户。我想踢一个特定的
    • 如果这解决了您的问题,请随时投票@Thatsmycarnow12
    猜你喜欢
    • 2021-06-08
    • 2019-05-30
    • 2021-07-28
    • 2021-09-13
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 2023-03-02
    • 2020-10-26
    相关资源
    最近更新 更多