question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: on_guild_remove Randomly Called on Start

See original GitHub issue

Summary

The on_guild_remove(guild) event is called randomly on start.

Reproduction Steps

  1. Create a bot instance
  2. Have an on_guild_remove(guild) function with some type of logging
  3. Start the bot
  4. Observe how the latest guilds are

Minimal Reproducible Code

import discord
from discord.ext import commands

class DiscordBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        super().__init__(intents=intents, command_prefix="!")
    
    async def on_guild_remove(self, guild: discord.Guild):
        print(f"[GUILD REMOVE] Name: {guild.name} | ID: {guild.id} | Object type: {type(guild)}")

bot = DiscordBot()
bot.run("YOUR_TOKEN")

Expected Results

The event is not called unless the bot is removed from a guild.

Actual Results

The event is called with the most recent guild changes at start.

Intents

default

System Information

  • Python v3.9.13-final
  • discord.py v2.0.0-final
  • aiohttp v3.8.1
  • system info: Windows 10 10.0.19044 (Also happens in ubuntu)

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

ItsWilliboy#1337 can reproduce this bug, as per: https://canary.discord.com/channels/336642139381301249/1009882344578097214/1009902388196421662

Image of logging (INFO): image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dolfiescommented, Aug 19, 2022

This happens when you’re in a guild TnS has soft-deleted.

0reactions
nmsturckecommented, Aug 19, 2022

Alright, thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

python sequential bugs when call function more than one time
In my fonction i secure copy with def copyDict(d): r = dict()# no ref for y in d: r[y]=d[y][:] #[:] no ref return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found