Closed burgerhex closed 6 years ago
It seems like you're using the Rewrite branch, where servers are now referred to as guilds.
See https://discordpy.readthedocs.io/en/rewrite/api.html#discord.Message.guild
As for the optional part, if a message is from a DM, message.guild
will return None
.
For future questions like this, you should join either the official discord.py server or the Discord API server for help, as the README recommends.
This page no longer exists. Also, docs that I find say to use "guilds", yet the version I have works with "servers". I installed discord.py via pip, so I'm confused as to why it appears I do not have the rewrite version.
Please don't necrobump issues.
The page no longer exists because the rewrite branch was released as v1 and has since been deleted. The latest version of that documentation would be at https://discordpy.readthedocs.io/en/latest/api.html#discord.Message.guild. For help migrating to v1, see https://discordpy.readthedocs.io/en/latest/migrating.html.
For instructions for installing the library, see https://github.com/Rapptz/discord.py#installing.
Make sure you're installing discord.py
and not a mirror package on PyPI like discord
.
Also make sure you're installing it for the Python version that you're using.
For further help, you should join either the official discord.py server or the Discord API server, as the README also links.
I'm currently writing a Discord bot in Python, but I am having some trouble getting the server's name from the user's sent message. This is the code I have written:
Python throws this error back at me:
AttributeError: 'Message' object has no attribute 'server'
I tried reading the documentation for
discord.Message
, but it says that themessage.server
attribute is "optional." What does that mean and/or how can I go around that?Thanks in advance.