久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Discord bot 在用戶響應(yīng)后無意中發(fā)送垃圾郵件

Discord bot unintentionally spamming messages after user response(Discord bot 在用戶響應(yīng)后無意中發(fā)送垃圾郵件)
本文介紹了Discord bot 在用戶響應(yīng)后無意中發(fā)送垃圾郵件的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在制作一個(gè)不和諧的機(jī)器人,它基本上可以檢測用戶在消息中發(fā)送的單詞,它會(huì)回復(fù)一條消息.但問題是我的機(jī)器人正在發(fā)送垃圾郵件而不是只發(fā)送一次.我不確定發(fā)生了什么,我在整個(gè)互聯(lián)網(wǎng)上尋找解決方案但找不到解決方案,這就是我來這里尋求幫助的原因.

I am making a discord bot that basically detects a word the user sends in a message and it will reply with a message. But the problem is that my bot is spamming the message instead of sending the message just once. I am not sure what is happening, I've looked all over the internet for a solution and couldn't find one which is why I came here for help.

                let Discord;
                let Database;
                if(typeof window !== "undefined"){
                    Discord = DiscordJS;
                    Database = EasyDatabase;
                } else {
                    Discord = require("discord.js");
                    Database = require("easy-json-database");
                }
                const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
                const s4d = {
                    Discord,
                    client: null,
                    tokenInvalid: false,
                    reply: null,
                    joiningMember: null,
                    database: new Database("./db.json"),
                    checkMessageExists() {
                        if (!s4d.client) throw new Error('You cannot perform message operations without a Discord.js client')
                        if (!s4d.client.readyTimestamp) throw new Error('You cannot perform message operations while the bot is not connected to the Discord API')
                    }
                };
                s4d.client = new s4d.Discord.Client({
                    fetchAllMembers: true
                });
                s4d.client.on('raw', async (packet) => {
                    if(['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)){
                        const guild = s4d.client.guilds.cache.get(packet.d.guild_id);
                        if(!guild) return;
                        const member = guild.members.cache.get(packet.d.user_id) || guild.members.fetch(d.user_id).catch(() => {});
                        if(!member) return;
                        const channel = s4d.client.channels.cache.get(packet.d.channel_id);
                        if(!channel) return;
                        const message = channel.messages.cache.get(packet.d.message_id) || await channel.messages.fetch(packet.d.message_id).catch(() => {});
                        if(!message) return;
                        s4d.client.emit(packet.t, guild, channel, message, member, packet.d.emoji.name);
                    }
                });
                s4d.client.login('tokenNumber').catch((e) => { s4d.tokenInvalid = true; s4d.tokenError = e; });



s4d.client.on('message', (s4dmessage) => {
  if (s4dmessage.content.includes('oranges')) {
    s4dmessage.channel.send(String('Yum! I love eating oranges!'));
  }

}
);

                s4d;
            

推薦答案

您的機(jī)器人會(huì)檢查消息中是否包含單詞 orange",如果包含,則發(fā)送它喜歡吃的響應(yīng) 橙色s.由于響應(yīng)還包含單詞 橙色",因此您的機(jī)器人會(huì)重復(fù)此功能,直到您受到速率限制.

Your bot checks if the message contains the word "orange" and if it does, sends a response that it loves eating oranges. As the response also contains the word "orange", your bot repeats this function until you're rate limited.

確保檢查 消息作者是否是一個(gè)機(jī)器人,如果是,只需使用 return 退出:

Make sure you check if the message author is a bot, and if it is, simply exit by using return:

s4d.client.on('message', (s4dmessage) => {
  if (s4dmessage.author.bot) return;
  if (s4dmessage.content.includes('oranges')) {
    s4dmessage.channel.send(String('Yum! I love eating oranges!'));
  }
});

這篇關(guān)于Discord bot 在用戶響應(yīng)后無意中發(fā)送垃圾郵件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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ù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 国产视频在线一区二区 | 国产ts人妖一区二区三区 | 色吊丝2288sds中文字幕 | 在线观看亚洲精品视频 | 日韩精品一区二区不卡 | 国产99久久久国产精品下药 | 国产一区久久 | 日韩精品一区二区三区在线观看 | 日韩亚洲一区二区 | 视频在线亚洲 | 国产精品小视频在线观看 | 久久久夜色精品亚洲 | 国产激情偷乱视频一区二区三区 | 欧美激情一区二区 | 成人三级电影 | 国产福利精品一区 | 日韩中文字幕在线免费 | 国产综合网站 | 精品一区二区免费视频 | 国产成人高清成人av片在线看 | 日本黄色大片免费 | 欧美一区二区三区日韩 | 亚洲成人一区二区三区 | 二区精品 | 日本午夜免费福利视频 | 中文字幕一区二区三区四区五区 | 99re国产视频| 中文一区二区 | 欧美精品在线免费观看 | 日韩精品中文字幕在线 | 中文字幕二区 | 国产精品美女www爽爽爽视频 | 欧美婷婷 | 一区二区在线不卡 | 成人精品一区二区三区中文字幕 | 羞羞视频免费观看入口 | 亚洲国产aⅴ成人精品无吗 国产精品永久在线观看 | 日韩国产在线观看 | 一区二区av | 国产精品高清一区二区三区 | 精品久久久久久亚洲精品 |