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

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

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

問題描述

我試過了:

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.

推薦答案

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

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 事件,然后像您一樣獲取頻道.此外,我們還檢查頻道是否未定義或為空,這意味著機器人無法找到頻道或沒有將其緩存.然后,我們加入并查看是否獲得返回連接.如果我們這樣做了,請將我們成功連接的事實記錄到控制臺.如果它沒有成功連接,我們將捕獲它并將其錯誤發(fā)送到控制臺.

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.

在調(diào)試時包含日志記錄以查看代碼運行的距離以及可能出現(xiàn)問題的位置總是一個好主意.在 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);

祝你好運,編碼愉快!

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

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

Error: FFMPEG not found

您可以看到您當(dāng)前沒有安裝 FFMPEG.要安裝 FFMPEG,請轉(zhuǎn)到 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.

這篇關(guān)于準(zhǔn)備好加入語音頻道(discord.js)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應(yīng))
Check if user ID exists in Discord server(檢查 Discord 服務(wù)器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創(chuàng)建我的第一個機器人,但總是錯誤 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 | 日韩欧美精品 | 亚洲国产一区在线 | 一二区视频 | 黄色成人在线观看 | av黄色在线观看 | 欧美午夜一区二区三区免费大片 | 久久国产综合 | 91大神在线资源观看无广告 | 欧美激情欧美激情在线五月 | a在线视频| 中文精品久久 | 日本不卡一区二区三区在线观看 | 国产精品福利网 | 免费一级淫片aaa片毛片a级 | 成年精品| 免费一级黄色录像 | 在线观看国产 | 久久久久久综合 | 欧美aaa| 久草成人网| 欧美一区二区 | 中文字幕日韩欧美 | 精品免费国产一区二区三区 | 欧美一级二级视频 | 精产国产伦理一二三区 | 国产成人在线视频播放 | 久久久青草婷婷精品综合日韩 | 欧美精品网站 | 日韩av最新网址 | 国产成人精品久久二区二区 | 一级做a爰片久久毛片 |