简体   繁体   中英

Discord.py AttributeError: 'str' object has no attribute 'server'

Can you help me why I keep getting this error? AttributeError: 'str' object has no attribute 'server'

@commands.has_role("customer")
async def email(ctx,count=None,bomb_email=None,*,message=None):
    if message.server is not None:
        await ctx.send("nope")
    else:
        x = int(count)
    if message.server is not None:
        await ctx.send("yes")
        
    else:
        await ctx.send("nope")

If you want to get command's called server you can change message.server with ctx.guild .

The problem is, you're trying to access a attribute called server which is not present the the str class. What I think you want is the discord.Message object. And even if you do that, there is no attribute called server for the Message class as well. I think what you need is the guild attribute which returns a discord.Guild object or None .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM