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

Discord Bot 無法按名稱獲取頻道

Discord Bot Can#39;t Get Channel by Name(Discord Bot 無法按名稱獲取頻道)
本文介紹了Discord Bot 無法按名稱獲取頻道的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我一直在制作一個不和諧的機器人,并想讓它向特定的歡迎"頻道發送消息.不幸的是,我一直無法這樣做.我試過了.

I have been making a discord bot and wanted to make it send a message to a specific "Welcome" channel. Unfortunately, I have been unable to do so. I tried this.

const welcomeChannel = bot.channels.get("name", "welcome")
welcomeChannel.sendMessage("Welcome
"+member.user.username);

但是在這個welcomeChannel 未定義"中.

However in this "welcomeChannel is undefined".

我嘗試過使用

const welcomeChannel = bot.channels.get("id", "18NUMBERIDHERE")
welcomeChannel.sendMessage("Welcome
"+member.user.username);

但這仍然是未定義的,奇怪的是

but this is still undefined, strangely

推薦答案

您應該使用頻道 id 而不是頻道名稱.

You should use the channnel id instead of it's name.

如何獲取頻道的頻道ID:

How to get the channel id of a channel:

  1. 打開您的 Discord 設置

  1. Open up your Discord Settings

轉到外觀

勾選開發者模式(并關閉Discord設置)

Tick Developer Mode (And close the Discord settings)

右鍵點擊你想要的頻道

現在有一個選項Copy ID來復制頻道ID

Now there's an option Copy ID to copy the channel id

還可以查看 discord.js 文檔 用于(頻道)收藏

Also checkout the discord.js documentation for (channel) collections

此外,您的方法將不起作用,因為 .get 需要頻道 ID(請參閱上面的鏈接文檔).如果您真的想通過名稱獲取頻道,請改用 .find.
但是,如果您的機器人在多個服務器上運行,這是一個非常糟糕的主意,因為頻道名稱現在可以出現多次.

Furthermore your approach won't work because .get wants a channel id (see the linked documentation above). In case you REALLY want to get an channel by its name, use .find instead for that.
This is however a really bad idea in case your bot runs on more than one server since channel names can now occur multiple times.

這篇關于Discord Bot 無法按名稱獲取頻道的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)
主站蜘蛛池模板: 国产精品久久久久久久久久久新郎 | 国产精品久久久av | 欧美日韩亚洲一区 | 欧美最猛黑人 | 国产婷婷色综合av蜜臀av | 国产乱人伦精品一区二区 | 蜜桃在线一区二区三区 | 欧美xxxx网站 | 天天天操操操 | 性色在线 | 精品久久久网站 | 国产片侵犯亲女视频播放 | 亚洲一区免费在线 | 亚洲欧美日韩在线一区二区 | 久久久久国产一区二区三区四区 | 亚洲狠狠 | 国产婷婷综合 | 成人免费视频网站在线看 | 在线亚洲免费 | 国产精品夜夜夜一区二区三区尤 | 亚洲成色777777在线观看影院 | 日韩欧美国产精品 | 亚洲综合一区二区三区 | 国产视频精品视频 | 成人欧美一区二区 | 欧美二区三区 | 欧美日韩亚洲二区 | 精品国产一区二区国模嫣然 | 国产精品美女久久久久aⅴ国产馆 | 另类视频区 | 中文字幕一区二区三区四区五区 | 亚洲日本国产 | 欧美在线综合 | 97色在线视频 | 欧美国产日韩精品 | 午夜精品91 | 精品国产一区二区三区久久久久久 | 久久av影院| 91久久久久| 国产精品美女一区二区三区 | 午夜在线 |