久久久久久久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?)
主站蜘蛛池模板: 亚洲精品在线看 | 国产精品一区二区不卡 | 色综合久久天天综合网 | 国产精品区一区二 | www.亚洲免费 | 欧美xxxx色视频在线观看免费 | 一级片av| 国产二区av| 成人国产免费视频 | 国产成人精品一区二 | 久久精品一区 | 日韩精品一区二区三区视频播放 | 在线视频亚洲 | 亚洲欧美日本在线 | 久久成人综合 | 欧美一级电影免费 | 欧产日产国产精品99 | 日韩精品视频网 | 日韩中文不卡 | 国产精品亚洲综合 | 日韩精品免费一区二区在线观看 | 天天操天天干天天曰 | 亚洲第一天堂无码专区 | 日本一区二区不卡 | 国产成人在线视频播放 | 免费日本视频 | 九九热这里只有精品6 | 日韩在线看片 | 亚洲一区二区三区免费观看 | 亚洲交性 | 手机看片在线播放 | 国产高清一区二区三区 | 91香蕉视频在线观看 | 99精品视频在线观看 | 一区二区三区久久 | 97视频在线观看网站 | 激情亚洲 | 亚洲一区二区在线播放 | 亚洲成人精品一区二区 | 国产欧美在线 | 午夜免费观看网站 |