简体   繁体   English

我对 discord.js rpc 有错误? 有人可以帮帮我吗?

[英]I have an error for discord.js rpc! Can someone please help me?

This is my error:这是我的错误:

(node:42087) UnhandledPromiseRejectionWarning: Error: Could not connect
    at Socket.onerror (/Users/vinesh/RPC/node_modules/discord-rpc/src/transports/ipc.js:32:16)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:42087) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:42087) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My code:我的代码:

const RPC = require('discord-rpc');
const client = new RPC.Client({ transport: 'ipc' });
client.on('ready', () =>
{
    client.request('SET_ACTIVITY', {
        pid: process.pid,
        activity: {
            assets: {
                large_image: 'Coding'
            },
            details: 'Coding',
            buttons: [
                { label: 'Emperor', url: 'https://dsc.gg/invite-emperor' },
                { label: 'https://dsc.gg/invite-emperor', url: 'https://dsc.gg/invite-emperor' }
            ]
        }
    });
    console.log('started!');
});
client.login({ clientId: 'My_ID' });

How do I fix this?我该如何解决? Is it because the code is old?是不是因为代码太旧了? I don't know why it does that.我不知道为什么会这样。 I did npm init -y , npm install discord , and npm install discord-rpc .我做了npm init -ynpm install discordnpm install discord-rpc

If you are running the web browser version of Discord, RPC will not work.如果您运行的是 Discord 的 web 浏览器版本,则 RPC 将不起作用。 Instead download Discord for Desktop which is here .而是下载 Discord 桌面版,这里是。

If you are running Discord desktop then try this code.如果您正在运行 Discord 桌面,请尝试此代码。 Also remember to add your assets in https://discord.com/developers/applications/Application_ID/rich-presence/assets and make sure they are the same name in application and code.还记得在https://discord.com/developers/applications/Application_ID/rich-presence/assets中添加您的资产,并确保它们在应用程序和代码中的名称相同。 You need large_text so don't remove it.你需要large_text所以不要删除它。

var rpc = require("discord-rpc")
const client = new rpc.Client({ transport: 'ipc' })
client.on('ready', () => {
    client.request('SET_ACTIVITY', {
        pid: process.pid,
        activity : {
            details : "Coding",
            assets : {
                large_image : "Your Image",
                large_text : "Your Status"
            },
            buttons : [{label : "Emperor" , url : "https://dsc.gg/invite-emperor"},{label : "Invite 2?",url : "https://dsc.gg/invite-emperor"}]
        }
    })
})
client.login({ clientId : "CLIENT_ID" }).catch(console.error);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的 Discord.JS 代码有一个奇怪的错误,你能帮我解决这个问题吗? - My code for Discord.JS is having a strange error, can you please help me solve this? discord.js中的“未定义”错误,有人可以帮助我吗? - “Undefined” Error in discord.js, can somebody help me? 请帮我处理我的 discord.js userinfo 命令 - Please help me with my discord.js userinfo command Discord.js - 类型错误:无法读取未定义的属性“声音”。 有人可以告诉我我做错了什么吗? - Discord.js - TypeError: Cannot read property 'voice' of undefined. Can someone tell me what I'm doing wrong? 有人可以解释一下并简化我在angular js中使用过的这个特定功能addButton()吗? - Can someone please explain me and simplify this particular function addButton() that I have used in angular js 我的 Discord 机器人的提及帮助命令不起作用。 有人可以帮忙吗? (Discord.js,JavaScript) - My Discord bot's mention help command is not working. Can someone help out? (Discord.js, JavaScript) 我正在尝试打开我的 discord 机器人。 但它向我展示了这条信息。 我安装了 discord.js - I am trying to open my discord bot . But it shows me this message . I have discord.js installed 有人可以帮助我解决这个错误吗? - can someone help me with this error? 如何获得 discord.js 中的公会数量 - How I can have the number of guilds in discord.js 如何让 discord.js 向某人发送 dm - How to have discord.js send a dm to someone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM