`discord.Message.guild` is always `None`
See original GitHub issueSummary
discord.Message.guild
is always None
everytime in on_message
event
Reproduction Steps
- make simple
on_message
event - try access any value inside
message.guild
likemessage.guild.id
- run and try say anything inside a guild
- errors
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\moopi\AppData\Local\pypoetry\Cache\virtualenvs\botjam_mod-WKqEDRqB-py3.9\lib\site-packages\discord\client.py", line 375, in _run_event
await coro(*args, **kwargs)
File "F:\Desktop\botjam mod\src\automod.py", line 138, in on_message
await self.profanity_checker(message)
File "F:\Desktop\botjam mod\src\automod.py", line 90, in profanity_checker
if db[str(message.guild.id)]["prevent_swearing"] == False:
AttributeError: 'NoneType' object has no attribute 'id'
Minimal Reproducible Code
import discord
from discord.ext import commands
class g(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
message.guild.id
async def setup(bot: commands.Bot):
await bot.add_cog(g())
Expected Results
discord.Message.guild.id
isn’t None
Actual Results
discord.Message.guild.id
is None
Intents
discord.Intents.all()
System Information
- Python v3.9.7-final
- discord.py v2.0.0-alpha
- discord.py pkg_resources: v2.0.0a4154+g832d2c05
- aiohttp v3.8.1
- system info: Windows 10 10.0.19044
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
No response
Issue Analytics
- State:
- Created a year ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
discord js message.guild is always null message.member
A message sent in private message to the both will not have a guild property, there is also the possibility of partials but...
Read more >get_member returns none always #5867 - Rapptz/discord.py
A recent update to Discord seems to have caused get_member when using a guild to not return the member. There was a sudden...
Read more >get_member always returns None (discord.py) : r/Discord_Bots
I'm trying to get my bot to 'fetch' member object from user id as an int. I have all Privileged Gateway Intents turned...
Read more >API Reference - discord.py
The number of guilds to retrieve. If None , it retrieves every guild you have access to. Note, however, that this would make...
Read more >Discord Developer Portal — Documentation — Guild
ALL_MESSAGES, 0, members will receive notifications for all messages by default ... NONE, 0, guild has not unlocked any Server Boost perks.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i figured it out
Yes.
If you want to further debug this issue turn on logging and print out what message.channel is.