简体   繁体   中英

I dont know why my discord bot cant read the messages?

well im making a discord bot for my server and it cant see when someone is typing something in general all tho everything seems to be fine the output stays 'mag_cecito#1080 said: '' (︱︱)'

from imaplib import Commands
import discord
import responces

async def send_message(message, user_message, is_private):
    try:
        responce = responces.handle_responce(user_message)
        await message.author.send(responce) if is_private else await message.channel.send(responce)
    except Exception as e:
        print(e)


def run_disocrd_bot():
    TOKEN = 'MTAxNzcxOTYxNjQzMDE2MTkyMA.G6gR5I.DyNWFqtwynSFYLr5MyKTaJ3gC47ZjGNAcR8-YY'
    intents = discord.Intents(messages=True, guilds=True)
    client = discord.Client(command_prefix="!", intents=intents)

    @client.event
    async def on_ready():
        print(f'{client.user} is now running')

    @client.event
    async def on_message(message):
        if message.author == client.user:
            return
    
        username = str(message.author)
        user_message = str(message.content)
        channel = str(message.channel)

        print(f"{username} said: '{user_message}' ({channel})")
        
    client.run(TOKEN)

thats pretty much the code pls help

If you are using a selfbot, then it's because you can't view messages in guilds using a selfbot as well as selfbots being unsupported in versions bigger than 1.7.3 . If not then I'm guessing you can't run your token from a function. Just run your token from main.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM