久久久久久久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 | h片在线看 | 日本在线精品视频 | 91九色porny首页最多播放 | 久久久久亚洲精品 | 久久精品亚洲一区二区三区浴池 | 黄免费看 | 欧美激情视频一区二区三区在线播放 | 亚洲一区二区在线播放 | 特黄小视频 | 91精品国产综合久久久亚洲 | 99精品国产在热久久 | 国产视频三区 | 亚洲性人人天天夜夜摸 | 午夜专区 | 在线免费观看日本 | 91天堂网| 欧美三级三级三级爽爽爽 | 福利视频一二区 | 中文字幕一区二区三区精彩视频 | 天天操 夜夜操 | www.国产精 | 一级黄色影片在线观看 | 成人九色 | 99re视频这里只有精品 | 国产精品成人69xxx免费视频 | 国产不卡一区 | 国产精品久久久久久久久久三级 | 欧美黄在线观看 | 日韩欧美精品在线播放 | 久久久成 | 欧美成人免费 | 天天干天天操天天爽 |