小编And*_*dré的帖子

循环雪花阵列

我正在寻找一种从这个Collection中获取数据的方法.

数据看起来像:

  '0000000' => GuildMember {
  guild:
   Guild {
     members: [Object],
     id: '000000',
     name: 'Zombie',
     _rawVoiceStates: [Object] },
  user:
   User {
     id: '0000000',
     username: 'Orc',
  _roles: [ '0000' ],
  nickname: 'Orc',
  joinedTimestamp: 00000,
  lastMessageID: null },

  '0000000' => GuildMember {
  guild:
   Guild {
     members: [Object],
     id: '000000',
     name: 'Zombie',
     _rawVoiceStates: [Object] },
  user:
   User {
     id: '0000001',
     username: 'Orc1',
  _roles: [ '0000' ],
  nickname: 'Orc',
  joinedTimestamp: 00000,
  lastMessageID: null },
  _array: null,
  _keyArray: null }
Run Code Online (Sandbox Code Playgroud)

我目前的循环是:

var user;
for(var u …
Run Code Online (Sandbox Code Playgroud)

javascript node.js discord discord.js

4
推荐指数
1
解决办法
6585
查看次数

如何获得漫游器来提及频道?

我正在发出欢迎消息,但似乎无法说出规则频道。我希望该机器人说出#rules并使其生效,因此您可以单击它进入规则频道。我知道您可以使用普通用户来执行此操作,但是我想使用我的机器人来执行此操作。每次尝试时,都无法像普通播放器一样单击它。我尝试做#rules,<#channelID>和其他内容。它们都不是可单击的。

javascript node.js discord discord.js

4
推荐指数
1
解决办法
8042
查看次数

收到表情符号反应后的 Discord.js 消息

一旦先前的消息收到反应,是否可以让 Discord 机器人发送消息?我在想这样的事情:

if(cmd === `${prefix}list`) {
    var i = 0;

    let embed = new Discord.RichEmbed()
      .addField("List", "Content");

    let anotherembed = new Discord.RichEmbed()
      .addField("Message", "List has been completed!");

    return message.channel.send(embed);

    do {
      message.channel.send(anotherembed + 1);
    }
    while (i !== 0) && (reaction.emoji.name === "?");

}
Run Code Online (Sandbox Code Playgroud)

javascript do-while discord.js

4
推荐指数
1
解决办法
3万
查看次数

机器人回复消息作者

我已经创建了自己的 Node.js 机器人来在我的 Discord 服务器中工作。

我的机器人名为mybot.

我见过许多响应传入消息的示例 - 它们看起来像这样(并且工作正常)。

chatroom.on('message', function(msg){
    if(msg.content === 'ping'){
        msg.reply('pong');
    }
});
Run Code Online (Sandbox Code Playgroud)

每当有人在频道中只写“ping”时,上面的代码都会让机器人回复“pong”。

与大多数机器人一样,通常您会与他们交谈并要求他们提供类似的东西@mybot blahblahblah- 然后他们会回复。

我想做这个。我只想mybot在和他说话时回复。必须有一个msg.recipientListormsg.recipients捕获@mybot. 我浏览了 Discord.js 的文档,但很难找到这个结果。

node.js discord discord.js

3
推荐指数
1
解决办法
1万
查看次数

Discord.js删除单个消息

我目前正在使用Discord.js创建一个Discord机器人,我想拥有一个您可以告诉它的命令||say Hello或类似的命令,它将删除您的注释,然后说出您要告诉的内容。

我当前的代码是

client.on('message', message => {
   if (message.content.startsWith("||say ")) {
      message.delete(1000); //Supposed to delete message
      message.channel.send(message.content.slice(5, message.content.length));
   }
});
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。

javascript node.js discord discord.js

3
推荐指数
1
解决办法
2万
查看次数

订单不一致js中的反应

我想添加一条带有反应的消息,但我希望反应具有一定顺序。问题是当我执行命令添加该消息时,反应会随机添加。

码:

        case "helptest":
	indexTest = 0;
	comandUser = message.author.username;
	message.channel.send(mesajeTest[indexTest]).then(function (message) {
		message.react("?")
		message.react("?")
		message.react("?")
		message.react("?")
	});
	break;
Run Code Online (Sandbox Code Playgroud)

我希望代码中的顺序在反应消息中,任何解决方案?

javascript node.js discord discord.js

3
推荐指数
1
解决办法
3516
查看次数

从 discord.js 中的消息中获取 Emoji url

我试图让我的不和谐机器人显示表情符号的图像文件。所以你发布了一个表情符号,机器人回复了一个附加的表情符号图像。

它适用于机器人在线的服务器的表情符号。但是如何从其他服务器获取表情符号的网址?

我使用 bot.emojis.get 搜索表情符号但是我如何搜索客户端“bot”的“外部”?或者以不同的方式获取网址?

我的来自加入服务器的表情符号代码:

const emoji = bot.emojis.get(emojiID);

await message.channel.send({files: [
{
  attachment: emoji.url,
  name: emoji.name + '.png'
}
]});
Run Code Online (Sandbox Code Playgroud)

另一个问题是emoji.animated一直在返回undefined。为什么? https://discord.js.org/#/docs/main/stable/class/Emoji?scrollTo=animated

javascript node.js emoji discord discord.js

3
推荐指数
1
解决办法
2万
查看次数

检查消息的作者是否是管理员

我正在编写一个 Discord 机器人,它使用以下代码来检测和处理用户消息:

bot.on('message', function (user, userID, channelID, message, evt) {
  //Message handling and response code goes here
});
Run Code Online (Sandbox Code Playgroud)

我想添加一个只有在发送它的用户具有管理员权限时才有效的命令。有没有办法做到这一点?

javascript bots node.js discord discord.io

3
推荐指数
1
解决办法
9920
查看次数

批量删除如何工作?

我尝试使用bulkDelete让我的机器人删除其消息,但出现此错误:

(node:5724) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Bad Request
(node:5724) 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.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

const Discord = require('discord.js');
const bot = new Discord.Client();
const config = require("./config.json");

bot.on('ready', () =>{
    console.log('I am ready!');
});

//var cleanarr=[];

bot.on("message", message =>{
    if (message.author.bot) return;
var cleanarr=[];
        let command = message.content.split(" ")[0];
command = command.slice(config.prefix.length);

        let …
Run Code Online (Sandbox Code Playgroud)

javascript bots bulk discord discord.js

2
推荐指数
1
解决办法
3万
查看次数

client.startTyping 不是函数 (Discord.JS)

我正在尝试使用 NodeJS 和 DiscordJS 创建一个 Discord 机器人。但是,当我尝试使用该client.startTyping()功能时,参考https://github.com/hydrabolt/discord.js/issues/440http://discordjs.readthedocs.io/en/latest/docs_client.html,似乎返回一个错误,指出该函数不存在。我怎样才能解决这个问题?

https://pastebin.com/S25fiJaZ(完整代码)

client.startTyping(message.channel);
for (i = 0; i < (times + 1); i++) {
    message.channel.sendMessage(msg);
}
client.stopTyping(message.channel);
Run Code Online (Sandbox Code Playgroud)

这是错误:

TypeError: client.startTyping is not a function
    at Client.client.on (/home/ty/discordbot/index.js:68:16)
    at emitOne (events.js:115:13)
    at Client.emit (events.js:210:7)
    at MessageCreateHandler.handle (/home/ty/discordbot/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/home/ty/discordbot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:102:65)
    at WebSocketConnection.onPacket (/home/ty/discordbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:325:35)
    at WebSocketConnection.onMessage (/home/ty/discordbot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:288:17)
    at WebSocket.onMessage (/home/ty/discordbot/node_modules/ws/lib/EventTarget.js:103:16)
    at emitTwo (events.js:125:13)
    at WebSocket.emit (events.js:213:7)
Run Code Online (Sandbox Code Playgroud)

javascript node.js discord discord.js

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

discord ×9

discord.js ×9

javascript ×9

node.js ×8

bots ×2

bulk ×1

discord.io ×1

do-while ×1

emoji ×1