当前位置: 首页 > 知识库问答 >
问题:

如何使discord机器人在以discord格式发送消息后产生表情符号反应。js?

楚流觞
2023-03-14

在机器人发送消息后,我想要一个表情符号反应。下面的代码仅在我键入命令后执行。例如,以下是一些示例输出:

输出不正确:

用户输入:规则显示表情反应机器人消息

正确输出:用户输入:规则Bot消息显示有表情反应

client.on('message', (rules) => {
    const listen = rules.content; 
    if(listen === 'rules') {
        rules.channel.send('```**1. Be respectful**\r\n' +
        'You must respect all users, regardless of your liking towards them.\r\n\r\n' + 
        '**2. No Inappropriate Language**\r\n' +
        'The use of profanity should be kept to a minimum.\r\n\r\n' +
        '**3. No spamming**\r\n' + 
        'Don\'t send a lot of small messages right after each other. Do not disrupt chat by spamming.\r\n\r\n' + 
        '**4. No pornographic/adult/other NSFW material**\r\n' +
        'This is a community server and not meant to share this kind of material.\r\n\r\n' +
        '**5. No advertisements**\r\n' +
        'We do not tolerate any kind of advertisements, whether it be for other communities or streams.\r\n\r\n' + 
        '**6. No offensive names and profile pictures**\r\n' +
        'You will be asked to change your name or picture if the staff deems them inappropriate.\r\n\r\n' +
        '**7. Server Raiding**\r\n Raiding or mentions of raiding are not allowed.\r\n\r\n' +
        '**8. Direct & Indirect Threats**\r\n' +
        'Threats to other users of DDoS, Death, DoX, abuse,' + 
        'and other malicious threats are absolutely prohibited and disallowed.\r\n\r\n' +
        '**9. Follow the Discord Community Guidelines**\r\n' +
        'You can find them here: https://discordapp.com/guidelines \r\n\r\n' +
        '**10. Admins and higher roles have greater responsibility**\r\n' + 
        'The Admins and Mods will Mute/Kick/Ban per discretion.\r\n' + 
        'If you feel mistreated dm an Admin and we will resolve the issue.```\r\n' +
        '**Your presence in this server implies accepting these rules, including all further changes.\r\n' +
        'These changes might be done at any time without notice, it is your responsibility to check for them.**').then(rules.react(emojiArray[1]));
       
    }
})

共有1个答案

凌声
2023-03-14
js prettyprint-override">client.on('message', (rules) => {
    const listen = rules.content; 
    if(listen === 'rules') {
        rules.channel.send('```**1. Be respectful**\r\n' +
        'You must respect all users, regardless of your liking towards them.\r\n\r\n' + 
        '**2. No Inappropriate Language**\r\n' +
        'The use of profanity should be kept to a minimum.\r\n\r\n' +
        '**3. No spamming**\r\n' + 
        'Don\'t send a lot of small messages right after each other. Do not disrupt chat by spamming.\r\n\r\n' + 
        '**4. No pornographic/adult/other NSFW material**\r\n' +
        'This is a community server and not meant to share this kind of material.\r\n\r\n' +
        '**5. No advertisements**\r\n' +
        'We do not tolerate any kind of advertisements, whether it be for other communities or streams.\r\n\r\n' + 
        '**6. No offensive names and profile pictures**\r\n' +
        'You will be asked to change your name or picture if the staff deems them inappropriate.\r\n\r\n' +
        '**7. Server Raiding**\r\n Raiding or mentions of raiding are not allowed.\r\n\r\n' +
        '**8. Direct & Indirect Threats**\r\n' +
        'Threats to other users of DDoS, Death, DoX, abuse,' + 
        'and other malicious threats are absolutely prohibited and disallowed.\r\n\r\n' +
        '**9. Follow the Discord Community Guidelines**\r\n' +
        'You can find them here: https://discordapp.com/guidelines \r\n\r\n' +
        '**10. Admins and higher roles have greater responsibility**\r\n' + 
        'The Admins and Mods will Mute/Kick/Ban per discretion.\r\n' + 
        'If you feel mistreated dm an Admin and we will resolve the issue.```\r\n' +
        '**Your presence in this server implies accepting these rules, including all further changes.\r\n' +
        'These changes might be done at any time without notice, it is your responsibility to check for them.**').then(r => r.react(emojiArray[1]));
       
    }
})

我不确定是否理解您的问题,但请尝试上面的代码。

 类似资料:
  • 我在尝试让我的discord机器人添加基于表情符号反应的角色时遇到问题。当我使用该命令时,我的机器人将嵌入消息和表情符号,但表情符号不可点击。另外,当我键入命令时,我会得到未处理的PromisejectionWarning:DiscordAPIError:Unknown表情符号错误(节点:12916) }

  • 我试图使用Discord JDA API发送消息,但是每当我发送一条消息时,它就会无限地发送。 JDA版本:4.2.1_255 我尝试过什么: 使用GuildMessageReceivedEvent而不是MessageReceivedEvent来研究此问题 伪代码: SendPrivate ateMessage():

  • 我有一个警告脚本,你基本上警告duh,它工作,但每次它发送一个不需要的消息 这是我的剧本 我很确定这是一个错误,但我只是想确定我在这里问过它,任何帮助都是感激的

  • 因此,我用于让bot问候新用户的代码停止工作,我不知道为什么或如何使用这是im用于欢迎活动本身的代码```module.exports=(client)=>{const channelId='757493821251649608'//welcome channel const targetChannelId='757521186929246219'//rules and info }``` 这就是

  • 我正在为我的Discord服务器创建一个bot。 我的服务器中有一个新的用户通道。当新用户加入时,我想向这个频道发送欢迎消息。但是,我不知道如何才能访问新用户的渠道。