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

我正在嘗試編寫一個顯示我的我的世界服務(wù)器狀

I am trying to code a discord bot that shows the status of my minecraft server but The bot isn#39;t responding to the command not even with an error(我正在嘗試編寫一個顯示我的我的世界服務(wù)器狀態(tài)的不和諧機(jī)器人,但機(jī)
本文介紹了我正在嘗試編寫一個顯示我的我的世界服務(wù)器狀態(tài)的不和諧機(jī)器人,但機(jī)器人沒有響應(yīng)命令,即使出現(xiàn)錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

const {Client, RichEmbed, Intents, MessageEmbed } = require('discord.js');

 
const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
 
 
const token = 'token is a secret';
 
const PREFIX = '!';
 
bot.on('ready', () =>{
    console.log('Bot has come online.');
});
 
bot.on('messageCreate', message =>{
 
    
    let args = message.content.substring(PREFIX.length).split(' ')
 
    switch(args[0]){
        case 'mc':
            ping = require('minecraft-server-util')
 
 
            ping = ('ip', port, (error, reponse) =>{
                if(error) throw error
                const Embed = new RichEmbed()
                .setTitle('Server Status')
                .addField('Server IP', reponse.host)
                .addField('Server Version', reponse.version)
                .addField('Online Players', reponse.onlinePlayers)
                .addField('Max Players', reponse.maxPlayers)
                
                message.reply({ embeds: [Embed] });
            })
        break
 
    }
 
    })
 
bot.login(token);

它是否顯示任何錯誤.它只是在發(fā)出命令時沒有響應(yīng).請告訴我的代碼有什么問題..并請告訴我如何糾正它.如果我將 'messageCreate' 替換為 'message',機(jī)器人在發(fā)出命令時做出響應(yīng),但顯示錯誤消息(node:25372) DeprecationWarning: The message event is deprecated. Use messageCreate instead".請幫忙我:(

Niether is it showing any error. Its just not responding when the command is being issued. Please tell whats wrong with my code.. and please tell how I can correct it. in the line, "bot.on('messageCreate', message =>{..." if i am replacing 'messageCreate' with 'message', the bot is responding on issuing the command, but with an error message saying ' (node:25372) DeprecationWarning: The message event is deprecated. Use messageCreate instead'. Please help me :(

對這個問題的一些回復(fù)建議我替換行"ping = ('ip', port, (error, reponse) =>{" with "ping('ip', port, error, response) =>{"但隨后它給出了錯誤 ping is not a function.根據(jù)一些建議,我意識到RichEmbed()"已在 discord v12 中刪除,所以我嘗試用 const Embed = new MessageEmbed() 替換行 const Embed = new RichEmbed() 但不幸的是這也沒有幫助.但是機(jī)器人沒有響應(yīng)時命令已發(fā)出.問題是,它也沒有顯示任何錯誤消息,所以我無法捕捉到我出錯的地方.

Some replies to this question suggested me to replace the line " ping = ('ip', port, (error, reponse) =>{" with "ping('ip', port, error, response) =>{" but then it gives the error ping is not a function. On some suggestions i realised that "RichEmbed()" was removed in discord v12, so i tried replacing the line const Embed = new RichEmbed() with const Embed = new MessageEmbed() but unfortunately that also did not help. Yet the bot did not respond when the command was issued. The thing is, it also does not show any error message, so i am not able to catch where i have gone wrong.

推薦答案

試試去掉這行

            ping = ('ip', port, (error, reponse) =>{

并將其替換為

            ping('ip', port, (error, reponse) =>{

第一個是將變量 ping 設(shè)置為兩個字符串 'ip'port,第三個是函數(shù) (error,response) =>{},第二個是使用 ping 函數(shù)對你的代碼進(jìn)行實際操作

The first one is setting a variable ping to be two strings 'ip' and port and a third one who is a function (error,response) =>{}, the second one is using the ping function to actually do something on your code

這篇關(guān)于我正在嘗試編寫一個顯示我的我的世界服務(wù)器狀態(tài)的不和諧機(jī)器人,但機(jī)器人沒有響應(yīng)命令,即使出現(xiàn)錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時的歡迎消息)
主站蜘蛛池模板: 美女在线观看国产 | 人操人人 | 视频一区 国产精品 | 日韩一二三区视频 | 国产乱码精品一区二区三区中文 | 狠狠夜夜 | 久久久av| 一区二区三区视频在线 | 国产在线观 | 欧美福利三区 | 欧美狠狠操 | 一区二区三区电影在线观看 | 韩国欧洲一级毛片 | 老司机午夜性大片 | 久久久久久久久久久高潮一区二区 | 伊伊综合网| 欧美一区二区激情三区 | 天天玩天天操天天干 | 国产性网 | 一区二区三区小视频 | 国产一区二区三区色淫影院 | 日韩一区二区在线看 | 国内精品久久久久久久影视简单 | 一区二区三区中文字幕 | 日韩影院在线观看 | 国产日日操 | 黄色毛片免费看 | 亚洲电影一区二区三区 | 黄色大片免费网站 | 精精国产xxxx视频在线野外 | 韩日一区二区三区 | 国产精品自拍视频 | 亚洲欧美日韩精品久久亚洲区 | 成人h视频在线 | 中文字幕国产视频 | 欧美一级高清片 | 久久av一区二区三区 | 久久精品小视频 | 成人在线精品视频 | 国产亚洲精品精品国产亚洲综合 | 91久久久久久 |