久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Discord.js 機器人在提及時做出響應

Discord.js bot responds when mentioned(Discord.js 機器人在提及時做出響應)
本文介紹了Discord.js 機器人在提及時做出響應的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試讓我的 discord.js 機器人在被 ping 通時發送一條消息.我不確定如何做到這一點,所以我參考了這段代碼:

I'm trying to make my discord.js bot send a message when it is pinged. I was unsure how to do this so I referred to this code:

client.on('message', message => {
    if (message.content === '<@745648345216712825>') {
        message.channel.send('Message Here');
    }
});

但是,這不起作用.

另外,當有人提到特定用戶時,我的機器人是否可能會做出響應,例如,如果用戶在機器人響應的消息中的任何位置提及我?如果是的話,你能告訴我怎么做嗎?

Also, is it possible that my bot responds when a person mentions a specific user for example if I am mentioned by the user anywhere in a message the bot responds? If yes, can you show me how to do it?

推薦答案

Message 有一個名為 mentions,包含消息中提到的所有頻道、成員、角色和用戶.您可以使用方法 .has(data, [options]) of MessageMentions 查看是否提到了您的機器人.

Message has a property called mentions, which contains all the channels, members, roles, and users mentioned in the message. You can use the method .has(data, [options]) of MessageMentions to see if your bot was mentioned.

client.on("messageCreate", (message) => {
    if (message.author.bot) return false;

    if (message.content.includes("@here") || message.content.includes("@everyone") || message.type == "REPLY") return false;

    if (message.mentions.has(client.user.id)) {
        message.channel.send("Hello there!");
    }
});

在 Discord.JS v13 中,message 事件已重命名為 messageCreate.使用 message 仍然有效,但在您切換之前,您會收到棄用警告.

The message event has been renamed to messageCreate in Discord.JS v13. Using message will still work, but you'll receive a deprecation warning until you switch over.

這篇關于Discord.js 機器人在提及時做出響應的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應)
Check if user ID exists in Discord server(檢查 Discord 服務器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 亚洲日韩中文字幕一区 | 99热在线免费 | 黄色免费在线网址 | 久久精品99| 亚洲综合日韩精品欧美综合区 | 欧美日韩国产精品一区二区 | 四虎永久影院 | 中文字幕av一区 | 国产高清在线 | 视频一区二区在线观看 | 国产露脸对白88av | 日本在线一区二区三区 | 九色国产 | 偷拍第一页 | 国产成人精品久久 | 日本三级全黄三级三级三级口周 | 免费在线观看91 | 成人老司机 | 亚洲午夜久久久 | 免费一看一级毛片 | 99久久99热这里只有精品 | 一二三区av | 欧美亚洲视频 | 欧美成人精品一区二区三区 | 久久久亚洲 | 国产 欧美 日韩 一区 | 少妇精品亚洲一区二区成人 | 精品视频 免费 | 黄色网址在线播放 | av在线播放网 | 久久精品国产久精国产 | 在线视频a | 亚洲欧美国产毛片在线 | 亚洲成av人片在线观看 | 日韩av中文| www.黄色在线观看 | 中文字幕 在线观看 | 成年人视频免费在线观看 | 羞羞的视频免费看 | 不卡的av在线 | 欧美日韩专区 |