dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
688 stars 160 forks source link

Bot takes too long to load #577

Closed vxiwspy closed 7 months ago

vxiwspy commented 1 year ago

Summary

Self explanatory, logs given below

Reproduction Steps

just running the script

Code

import discord
from discord.ext import commands

tk = "awesome token"

bot = commands.Bot(command_prefix="!", self_bot=True)

@bot.event
async def on_ready():
    print("hello")

@bot.command()
async def slash(ctx):
    async for command in ctx.channel.slash_commands():
        if command.name == "rules":
            await command(ctx.channel)

bot.run(tk)

Expected Results

2023-09-19 15:00:24 INFO discord.client Logging in using static token. 2023-09-19 15:00:26 INFO discord.http Found user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36, build number 228672. 2023-09-19 15:00:35 INFO discord.gateway Connected to Gateway (Session ID: 7ab97b4d631fb86ebb02546d1ed41c0c). hello

Actual Results

2023-09-19 15:07:17 INFO discord.client Logging in using static token. 2023-09-19 15:07:21 INFO discord.http Found user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36, build number 228672. 2023-09-19 15:07:31 INFO discord.gateway Connected to Gateway (Session ID: fa72df575e46dadabe3c287a83663836). 2023-09-19 15:07:32 WARNING discord.state Member list scraping failed for 1103744573714464858 (Failed to automatically choose channels; please specify them manually). 2023-09-19 15:07:32 WARNING discord.gateway Gateway is ratelimited, waiting 53.32 seconds. 2023-09-19 15:07:32 WARNING discord.state Member list scraping failed for 1123804276980990052 (Failed to automatically choose channels; please specify them manually). 2023-09-19 15:07:32 WARNING discord.state Member list scraping failed for 920566723009216563 (Failed to automatically choose channels; please specify them manually). 2023-09-19 15:07:32 WARNING discord.state Member list scraping failed for 1075586947516473394 (Failed to automatically choose channels; please specify them manually). 2023-09-19 15:07:44 WARNING discord.state Timed out waiting for member list subscriptions for guild_id 1079833092681900152. 2023-09-19 15:07:54 WARNING discord.state Timed out waiting for member list subscriptions for guild_id 1105090950805594112. 2023-09-19 15:08:04 WARNING discord.state Timed out waiting for member list subscriptions for guild_id 1142510577823006750. 2023-09-19 15:08:14 WARNING discord.state Timed out waiting for member list subscriptions for guild_id 1067666411058638888. 2023-09-19 15:08:24 WARNING discord.state Timed out waiting for member list subscriptions for guild_id 1132097377382174761. hello

System Information

Checklist

Additional Information

No response

Asleep123 commented 11 months ago

Same thing happening for me.

koetsmax commented 11 months ago

Same here, seems to only happen on small guilds, I just removed the whole member scraping routine

Asleep123 commented 10 months ago

Same here, seems to only happen on small guilds, I just removed the whole member scraping routine

Can you tell me what file and lines that happens at?

l-404-l commented 8 months ago

Took me a bit of reading in the backend to figure out why starting a bot takes a bit. The way to make it start way faster is with a few parameters.

chuck_guilds_at_startup = Members request_guilds = typing/activities/threads

Both can be done manually after start if you don't want to wait for them. Some events still get pushed through without subscribing to these events. Usually needed if you're watching large discord servers.

import discord
from discord.ext import commands

tk = "awesome token"

bot = commands.Bot(command_prefix="!", self_bot=True, request_guilds=False, chunk_guilds_at_startup=False)

@bot.event
async def on_ready():
    print("hello")

@bot.command()
async def slash(ctx):
    async for command in ctx.channel.slash_commands():
        if command.name == "rules":
            await command(ctx.channel)

bot.run(tk)
dolfies commented 7 months ago

This wasn't exactly a bug, but fixed anyway.