5

Using the following lines of code:

@bot.command()
async def report(ctx):
  author = ctx.message.author
  server = ctx.message.server
  wait ctx.send("Author: " + str(author) + "\nServer: " + str(server))

I get the error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Message' object has no attribute 'server'

It's not a problem with importing the libraries because I can change the line to ctx.message.channel and get the channel name. The author collects fine too. But the server does not. I have also tried using Guild as per some recommendations with no luck.

5
  • What version of discord.py are you using? Try import discord; print(discord.__version__) if you're not sure. Commented Jun 1, 2018 at 21:41
  • I'm using version 1.0.0a which I believe is the rewrite version. Commented Jun 1, 2018 at 21:43
  • Message objects should have a guild attribute. So should context objects. Try ctx.guild and see what that gives you. How are you invoking the command? If you're doing it through private messages, there's no guild to get, but I would expect None instead Commented Jun 1, 2018 at 21:47
  • Invoking it as a command in a public channel in the server. As a side note, ctx.guild worked. I think I capitalized Guild like in the documentation and it failed. Thank you very much. Should I get rid of the question, or answer it? Commented Jun 1, 2018 at 21:54
  • @webneko you don't need to edit in the version info if it's already described in the tags (discord.py-rewrite), more unnecessary content only adds noice to the question. I think Patrick Haugh was only trying to be certain that you're using rewrite, since this is a version-dependent error. Commented Jun 2, 2018 at 6:14

1 Answer 1

15

discord.py rewrite version does not use Server to remove ambiguity between guilds and voice servers and to remain consistent with Discord's internal code.

Instead of doing

discord.Server
message.server
etc.server

Use

discord.Guild
message.guild
etc.guild
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.