-
SummaryMy bot have issue Expected ResultsI wanted my bot to show Do Not Disturb instead of dnd Actual ResultsTraceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'status' My Codeimport discord
from discord.ext import commands
from datetime import timedelta
from discord import ChannelType, Guild, Member, Message, Role, Status, utils, Embed
from discord.abc import GuildChannel
from discord.ext.commands import BucketType, Cog, Context, Paginator, command, group, cooldown
from datetime import datetime
import time
import random
class Info(commands.Cog):
def __init__(self, bot):
self.bot = bot
# Ping Command
@commands.command(aliases=['Latency'])
async def ping(self, ctx):
msg = await ctx.send("`Bot Latency...`")
times = []
counter = 0
embed = discord.Embed(title="More Information:", description="4 pings have been made and here are the results:", colour=discord.Color.red())
for _ in range(3):
counter += 1
start = time.perf_counter()
await msg.edit(content=f"Trying Ping... {counter}/3")
end = time.perf_counter()
speed = round((end - start) * 1000)
times.append(speed)
if speed < 160:
embed.add_field(name=f"Ping {counter}:", value=f"🟢 | {speed}ms", inline=True)
elif speed > 170:
embed.add_field(name=f"Ping {counter}:", value=f"🟡 | {speed}ms", inline=True)
else:
embed.add_field(name=f"Ping {counter}:", value=f"🔴 | {speed}ms", inline=True)
embed.set_author(name="🏓 **PONG** 🏓", icon_url="https://img.icons8.com/ultraviolet/40/000000/table-tennis.png")
embed.add_field(name="Bot Latency", value=f"{round(self.bot.latency * 1000)}ms", inline=True)
embed.add_field(name="Normal Speed", value=f"{round((round(sum(times)) + round(self.bot.latency * 1000))/4)}ms")
embed.set_footer(text=f"Total estimated elapsed time: {round(sum(times))}ms")
await msg.edit(content=f":ping_pong: **{round((round(sum(times)) + round(self.bot.latency * 1000))/4)}ms**", embed=embed)
# User Info Command
@commands.command(aliases=['whois', 'info'])
async def userinfo(self, ctx, member : discord.Member = None):
x = member.status
val = None
if x == discord.status.do_not_disturb:
val = 'Do Not Disturb'
member = ctx.message.author if not member else member
roles = [role for role in member.roles]
em = discord.Embed(colour=member.colour)
em.set_author(name=f"User Info - {member}")
em.set_thumbnail(url=member.avatar_url)
em.add_field(name="Display Name", value=member.display_name)
em.add_field(name="Tag", value=member, inline=True)
em.add_field(name="ID", value=member.id, inline=True)
em.add_field(name="Registered at:", value=member.created_at.strftime('%a, %#d %B %Y, %I:%M %p'), inline=False)
em.add_field(name="Joined at:", value=member.joined_at.strftime("%a, %#d %B %Y, %I:%M %p"), inline=True)
em.add_field(name=f"Roles ({len(roles)})", value=f" ".join([role.mention for role in roles]), inline=False)
em.add_field(name="Top Role", value=member.top_role.mention, inline=True)
em.add_field(name="Platform", value=f"{'Mobile' if member.is_on_mobile() else 'PC'}", inline=False)
em.add_field(name="Account Type", value=f"{'Bot' if member.bot else 'Human'}", inline=True)
em.add_field(name="Status", value=f"{val}.capitalize", inline=True)
em.add_field(name="Admin?", value=f"{member.guild_permissions.administrator}", inline=True)
em.set_footer(text=f"Requested by: {member}", icon_url=member.avatar_url)
em.timestamp = datetime.utcnow()
await ctx.send(embed=em)
def setup(bot):
bot.add_cog(Info(bot)) Checklist
System Information
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
The attribute is lowercase |
Beta Was this translation helpful? Give feedback.
-
Please try to help |
Beta Was this translation helpful? Give feedback.
-
Since you've edited the post now, these lines are nonsensical: x = member.status
val = None
if x == discord.status.do_not_disturb:
val = 'Do Not Disturb'
|
Beta Was this translation helpful? Give feedback.
Since you've edited the post now, these lines are nonsensical:
discord.status
doesn't exist, it'sdiscord.Status
because it's a class and classes are in PascalCase. Python is a case-sensitive languages.