#Dm message

1 messages · Page 1 of 1 (latest)

late pollen
#

show the actual error

errant mason
#

CODE:

`@bot.command()
@lightbulb.option("text", "text to send", modifier=lightbulb.OptionModifier.CONSUME_REST)
@lightbulb.option("user", "user to dm", type=hikari.OptionType.USER)
@lightbulb.command("mod-msg", "dm a message to a specific user")
@lightbulb.implements(lightbulb.SlashCommand)
async def msg(ctx: lightbulb.Context) -> None:
intents = hikari.Intents.ALL
user = ctx.options.user

if ctx.member.top_role.id in ["1116002289560334489", "789553780508196884", "745774589119955058",
                              "1005477841418342410", "1002339919672381582", "895342175305498655",
                              "963036389849583637"]:
    await user.send(ctx.options.text)
    await ctx.respond(
        embed=hikari.Embed(title="Erfolg!", description=f"{user.mention} Erfolgreich eine Nachricht gesendet"))
else:
    await ctx.respond(
        "Du hast nicht die nötigen Berechtigungen, um diesen Befehl auszuführen. Wenn du berechtigt sein solltest, melde dich bitte bei ApfelTeeSaft#7181")`

Error:

`Traceback (most recent call last):
File "C:\Users\Felix\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\lightbulb\app.py", line 1162, in invoke_application_command
await context.invoke()
File "C:\Users\Felix\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\lightbulb\context\base.py", line 334, in invoke
await self.command.invoke(self)
File "C:\Users\Felix\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\lightbulb\commands\base.py", line 798, in invoke
await self(context, **kwargs)
File "C:\Users\Felix\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\lightbulb\commands\base.py", line 712, in call
return await self.callback(context, **kwargs)
File "c:\Users\Felix\Documents\GitHub\Sector-7-Moderation-Tools\bot.py", line 62, in msg
if ctx.member.top_role.id in ["1116002289560334489", "789553780508196884", "745774589119955058",
AttributeError: 'InteractionMember' object has no attribute 'top_role'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Felix\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\lightbulb\app.py", line 1203, in handle_interaction_create_for_application_commands
await self.invoke_application_command(context)
File "C:\Users\Felix\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\lightbulb\app.py", line 1180, in invoke_application_command
raise new_exc
lightbulb.errors.CommandInvocationError: An error occurred during command 'mod-msg' invocation`

late pollen
#

read the error

#

an InteractionMember object has no attribute top_role

#

Nowhere in the docs suggests that to be the case