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

Discord bot 在用戶響應后無意中發送垃圾郵件

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

問題描述

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

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;
            

推薦答案

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

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.

確保檢查 消息作者是否是一個機器人,如果是,只需使用 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!'));
  }
});

這篇關于Discord bot 在用戶響應后無意中發送垃圾郵件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

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(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 欧美精品v国产精品v日韩精品 | 性福视频在线观看 | a级毛片免费高清视频 | 999观看免费高清www | 国产视频久| 中文字幕一区二区三区四区 | 日本精品久久 | 久久99精品久久久 | 91社区在线观看播放 | 免费国产精品久久久久久 | 国产精品美女久久久 | 久久69精品久久久久久久电影好 | 成人做爰www免费看视频网站 | 日韩成人免费视频 | 亚洲a在线观看 | 一级毛片免费视频观看 | 国产精品亚洲一区二区三区在线 | 国产成人在线视频 | 午夜不卡福利视频 | 91视频在线网站 | 性色的免费视频 | 欧美男人天堂 | av一区二区三区四区 | 亚洲成av人片在线观看 | 亚洲自拍偷拍免费视频 | 亚洲v日韩v综合v精品v | 99精品亚洲国产精品久久不卡 | 污视频免费在线观看 | 激情a| 免费观看www7722午夜电影 | 国产一级在线观看 | 成人毛片一区二区三区 | 午夜影院在线观看 | 午夜国产一级 | 九九热免费看 | 亚洲精品中文在线观看 | 日韩精品一区二 | 国产在线一区二区 | 国产高清视频在线观看 | 欧美精品久久久久久 | 国产精品一区二区三区久久 |