亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ROBLOX 不和諧機器人

ROBLOX 不和諧機器人

HUX布斯 2022-05-26 16:32:27
我正在嘗試創建一個連接到我創建的 Roblox 帳戶的不和諧機器人。我正在嘗試創建一個可以在組中喊出消息的命令,但是登錄時出現問題,我不知道如何解決該問題。let roblox = require('noblox.js');const { Client } = require("discord.js");const { config } = require("dotenv");const client = new Client({    disableEveryone: true});config({    path: __dirname + "/.env"});let prefix = process.env.PREFIXlet groupId = groupid;client.on("ready", () => {    console.log("I'm Ready!");function login() {    roblox.cookieLogin(process.env.COOKIE)}login()    .then(function () {        console.log(`Logged in to ${username}`);    })    .catch(function (error) {        console.log(`Login error: ${error}`);    });client.on("message", async message => {    console.log(`${message.author.username} said: ${message.content}`);    if (message.author.bot) return;    if (message.content.indexOf(prefix) !== 0) return;    const args = message.content.slice(prefix.length).trim().split(/ +/g);    const command = args.shift().toLowerCase();    if (command === "shout") {        if (!args) {             return;            message.reply("You didn't specify a message to shout.")        }        const shoutMSG = args.join(" ");         roblox.shout(groupId, shoutMSG)            .then(function() {                console.log(`Shouted ${shoutMSG}`);             })            .catch(function(error) {                 console.log(`Shout error: ${error}`)            });    }})client.login(process.env.TOKEN);它給了我錯誤: Shout error: Error: Shout failed, verify login, permissions, and message
查看完整描述

1 回答

?
江戶川亂折騰

TA貢獻1851條經驗 獲得超5個贊

一開始你不會關閉你的client.on('ready')狀態。


        if (!args) { 

            return;

            message.reply("You didn't specify a message to shout.")

        }

這個funcyion永遠不會回復,因為你在回復之前使用了return。


您的 groupId 看起來像undefined,因為您聲明了它let groupId = groupid;,所以這是一種方法,為什么會出現此錯誤。


let roblox = require('noblox.js');

const { Client } = require("discord.js");

const { config } = require("dotenv");


const client = new Client({

    disableEveryone: true

});


config({

    path: __dirname + "/.env"

});


let prefix = process.env.PREFIX

let groupId = groupid;


client.on("ready", () => {

    console.log("I'm Ready!");

})


function login() {

    roblox.cookieLogin(process.env.COOKIE)

}


login()

    .then(function () {

        console.log(`Logged in to ${username}`);

    })

    .catch(function (error) {

        console.log(`Login error: ${error}`);

    });


client.on("message", async message => {

    console.log(`${message.author.username} said: ${message.content}`);

    if (message.author.bot) return;

    if (message.content.indexOf(prefix) !== 0) return;


    const args = message.content.slice(prefix.length).trim().split(/ +/g);

    const command = args.shift().toLowerCase();


    if (command === "shout") {

        if (!args) return message.reply("You didn't specify a message to shout.")

        const shoutMSG = args.join(" "); 

        roblox.shout(groupId, shoutMSG)

            .then(function() {

                console.log(`Shouted ${shoutMSG}`); 

            })

            .catch(function(error) { 

                console.log(`Shout error: ${error}`)

            });

    }

})


client.login(process.env.TOKEN);


查看完整回答
反對 回復 2022-05-26
  • 1 回答
  • 0 關注
  • 119 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號