I am writing a script for a client that notifies you if someone asks for an editor in some specific channels.
However, the on_message() function doesn't detect messages on two servers (which are both partnered servers) but works on any other.
(Note that it is also running as a selfbot).
Here is the code:
import discord import time import json with open('config.json', 'r') as f: json_f = json.load(f) TOKEN = json_f['Token'] words = json_f['words'] channels = json_f['channels'] blacklist = json_f['blacklisted'] export_channel = json_f['export_channel'] blackl_users = json_f['blacklisted_users'] client = discord.Client() @client.event async def on_ready(): print('Ready !\nLogged as :', client.user.name) @client.event async def on_message(message): send_in = client.get_channel(export_channel) if message.author.id in blackl_users: return for i in blacklist: if i in message.content.lower(): return if (message.channel.id in channels)==False: return for i in words: if i in message.content.lower(): c_time = time.localtime(time.time()) m_time = str(c_time.tm_hour) + ':' + str(c_time.tm_min) + ' the ' + str(c_time.tm_mon) + '/' + str(c_time.tm_mday) + '/' + str(c_time.tm_year) title_content = 'Message found in the server "' + str(message.guild) + '" :' desc_content = '**Channel name :** #' + message.channel.name + '\n**Channel ID : **' + str(message.channel.id) + '\n\n**By : **' + str(message.author) + '\n**Author ID :** ' + str(message.author.id) + '\n\n**At : **' + m_time + '\n\n**Message ID : **' + str(message.id) + '\n**Message content :**\n' + message.content embed = discord.Embed(title=title_content, description=desc_content, color=0x7d34eb) await send_in.send(embed=embed) return client.run(TOKEN, bot=False)
https://stackoverflow.com/questions/66572307/discord-py-on-message-not-working-on-some-servers March 11, 2021 at 04:22AM
没有评论:
发表评论