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

準備好加入語音頻道(discord.js)

Joining a voice channel on ready (discord.js)(準備好加入語音頻道(discord.js))
本文介紹了準備好加入語音頻道(discord.js)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我試過了:

client.on('ready', () => {
  let channel = client.channels.get('432462518380789771');
  channel.join()
});

它不起作用.我確保 ID 是正確的,一切正常,但仍然無法正常工作.

It doesnt work. I made sure that the ID is right and everything and its still not working.

推薦答案

考慮到我們沒有關于您收到的錯誤的上下文,我將提供一個代碼示例,看看這是否能解決您的問題.

Considering we have no context on the error you're receiving, I'll provide a code example to see if this fixes your issue.

client.on("ready", () => {
  const channel = client.channels.get("mychannelid");
  if (!channel) return console.error("The channel does not exist!");
  channel.join().then(connection => {
    // Yay, it worked!
    console.log("Successfully connected.");
  }).catch(e => {
    // Oh no, it errored! Let's log it to console :)
    console.error(e);
  });
});

在這段代碼中,我們使用 ready 事件,然后像您一樣獲取頻道.此外,我們還檢查頻道是否未定義或為空,這意味著機器人無法找到頻道或沒有將其緩存.然后,我們加入并查看是否獲得返回連接.如果我們這樣做了,請將我們成功連接的事實記錄到控制臺.如果它沒有成功連接,我們將捕獲它并將其錯誤發送到控制臺.

In this code, we use the ready event and then get the channel, like you do. In addition, we also check if the channel is undefined or null, meaning the bot was unable to find the channel or did not have it cached. Then, we join and see if we get a returning connection. If we do, log to the console the fact we successfully connected. If it didn't successfully connect, we'll catch it and error it to console.

在調試時包含日志記錄以查看代碼運行的距離以及可能出現問題的位置總是一個好主意.在 Node.js 中,捕獲 unhandledRejections 也是一個好主意.否則,它們會使您的進程崩潰.您可以通過下面的代碼示例來做到這一點.

It's always a good idea when debugging to include logging to see how far your code runs, and to see where issues may occur. In Node.js, it's also a good idea to catch for unhandledRejections. Otherwise, they will crash your process. You can do that via the code example below.

process.on("unhandledRejection", console.error);

祝你好運,編碼愉快!

有了新信息,我現在很容易看到問題.請注意它在錯誤中的說明:

With the new information, I now very easily see the issue. Notice how in the error it says:

Error: FFMPEG not found

您可以看到您當前沒有安裝 FFMPEG.要安裝 FFMPEG,請轉到 this url 下載適用于您平臺的源代碼.查看 這個答案 看看如何在 Windows 上安裝它.

You can see that you do not currently have FFMPEG installed. To install FFMPEG, go to this url to download the sources for your platform. Check out this answer to see how to install it on Windows.

這篇關于準備好加入語音頻道(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?)
主站蜘蛛池模板: 亚洲国产精品一区二区三区 | 欧美freesex黑人又粗又大 | 国产高清精品一区二区三区 | 国产亚洲精品美女久久久久久久久久 | 久久久久久久久久久久一区二区 | 国产黄色av电影 | 二区高清 | 电影午夜精品一区二区三区 | 先锋资源在线 | 国产欧美在线 | 亚洲男人天堂网 | 新91视频网 | 成人av在线大片 | 四虎成人在线播放 | 国产传媒在线播放 | 日本高清视频网站 | 亚洲成人一级片 | 精品一二三区 | 欧美日韩国产在线观看 | www国产成人免费观看视频 | 日韩综合在线视频 | 成人在线观看免费观看 | 久久久精品国产 | 成人久久18免费网站图片 | 日韩高清国产一区在线 | 成人黄色av | 福利视频一二区 | 精品美女久久久 | 久久99精品久久久久婷婷 | 丁香五月网久久综合 | 另类在线 | 久久亚洲国产 | 妖精视频一区二区三区 | 亚洲在线中文字幕 | 亚洲欧美国产精品久久 | 欧美亚洲在线视频 | 精品国产高清一区二区三区 | 国产精品美女久久久久 | 精品国产伦一区二区三区观看体验 | 亚洲视频在线看 | 日韩欧美专区 |