Closed kintama48 closed 2 years ago
I have changed the code to use @bot.command()
event listener however I still get the same error when I use the command on guilded. Here's the updated code.
@bot.command(name="qr", description="Sends QR to a user for login")
async def qr(ctx):
current_time = now.strftime("%H:%M:%S")
if str(ctx.author.id) in ScholarsDict:
botPlaceHolders = ScholarsDict[str(ctx.author.id)]
accountPrivateKey = botPlaceHolders[2]
accountAddress = botPlaceHolders[1]
rawMessage = getRawMessage()
signedMessage = getSignMessage(rawMessage, accountPrivateKey)
accessToken = submitSignature(signedMessage, rawMessage, accountAddress)
qrCodePath = f"QRCode_{ctx.author.id}_{str(uuid.uuid4())[0:8]}.png"
generate_qr(accessToken, qrCodePath)
await ctx.author.send(
"Tips: If the qr code wont work, please try this steps. Delete the old qr on your device, and get a "
"new one again, "
"if that doesn't work then scan the qr code with another device."
+ ctx.author.name + "\nHere is your new QR Code to login : "
)
await ctx.author.send(file=guilded.File(qrCodePath))
os.remove(qrCodePath)
return ["bot_token"]
else:
print("This user didn't receive a QR Code because not added in SecretStorage: " + message.author.name)
print("Guilded ID: " + str(ctx.author.id))
print("Current time: ", current_time)
return
The Error I get
Ignoring exception in command qr:
Traceback (most recent call last):
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/ext/commands/core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "Cryptic-Scholars-QR-Code-Bot.py", line 62, in qr
"Tips: If the qr code wont work, please try this steps. Delete the old qr on your device, and get a "
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/user.py", line 213, in general
return await getattr(self._user, x)(*args, **kwargs)
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/abc.py", line 616, in send
await self.create_dm()
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/abc.py", line 591, in create_dm
data = await self._state.create_dm_channel([self.id])
AttributeError: 'HTTPClient' object has no attribute 'create_dm_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/ext/commands/bot.py", line 421, in invoke
await ctx.command.invoke(ctx)
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/ext/commands/core.py", line 619, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/kintama/Downloads/Cryptic-QR-Code-for-Guilded/venv/lib/python3.8/site-packages/guilded/ext/commands/core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
guilded.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'HTTPClient' object has no attribute 'create_dm_channel'
This is not so much a bug but moreso just confusing. Only users can create DMs, thus the create_dm_channel
method is only available if your HTTP Client was created by a UserbotClient
or UserbotBot
.
User.create_dm
should have the |onlyuserbot|
substitution but that's about it.
Describe the bug Hi, I am trying to migrate a bot from discord to guilded. The bot generates a QR code and sends it to a member of the guild. The member types
$qr
in a guild channel and the bot then DM's the QR code to the member. However, the bot fails to DM the member.To Reproduce This is the
on_message
event listener I am using.Expected behavior I expect the bot to DM the member the generated QR code
Actual behavior I get this error instead
Environment