#๐Ÿ”’ Discord bot erros

22 messages ยท Page 1 of 1 (latest)

covert groveBOT
#

@spring hemlock

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

spring hemlock
#

The problem comes down to it cant find the user id not allowing it to assing the role that the user responded with corealting number

iron eagle
#

can you pate the full traceback

spring hemlock
#

im using Replit btw but are u askign for the error before i made the error handler?

spring hemlock
#

Sunset Bot#1196 has connected to Discord!
Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "/home/runner/sunset-bot/.pythonlibs/lib/python3.10/site-packages/discord/client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "/home/runner/sunset-bot/main.py", line 143, in on_reaction_add
await accept_application(reaction.message.channel, reaction.message.id)
File "/home/runner/sunset-bot/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 505, in call
return await self.callback(context, *args, **kwargs) # type: ignore
File "/home/runner/sunset-bot/main.py", line 99, in accept_application
user_id = int(content_lines[0].split(': ')[1])
IndexError: list index out of range

slim sequoiaBOT
iron eagle
#

print out content_lines to see what it is:

    message = await admin_channel.fetch_message(message_id)
    await message.delete()
    await ctx.send("Application accepted successfully!")

    content_lines = message.content.split('\n')
+   print("content_lines:", content_lines)
spring hemlock
#

Sunset Bot#1196 has connected to Discord!
content_lines: ['Form submitted by {user.display_name}:', '', 'What is your Discord user ID?', '1204231317240283147', '', 'How old are you?', '15', '', 'How long have you been roleplaying for?', 'A', '', 'How active can you be?', 'A', '', 'Have you read the rules?', 'A', '', 'Which department do you want to join? Type the corresponding number:', '1 - Civ', '2 - Cop', '3 - LFD', '1', '', 'Explain what you would do if you are traveling at 75mph in a vehicle and hit a street light pole but your vehicle is able to continue.', 'A', '', 'Explain what you should do and/or not do if your character is on their back fully bled out from an injury.', 'A', '', 'Explain the definition of stream sniping in your own words.', 'A', '', 'Explain the definition of power-gaming in your own words.', 'A', '', 'Explain the definition of meta-gaming in your own words.', 'A', '', 'Explain the definition of RDM and VDM in your own words.', 'A', '', 'Are you allowed to use information you found out through another one of your own characters?', 'A', '', "You are out cruising the town with a good friend. Suddenly, your phone rings. It's another friend of yours. She says 'He's dead! What should I do?' and shares her location with you. What do you do? (minimum of 50 words)", 'THESE WERE DELTED THEY WERE THE N WORD 50 TIME CAUSE THE IDITO DOIGN IT WANT TO DO SOMETHING DUM']

slim sequoiaBOT
spring hemlock
#

?

iron eagle
#

This is where the error is happening:

user_id = int(content_lines[0].split(': ')[1])

Let's break it down
content_lines[0] turns into Form submitted by {user.display_name}:
splitting by : (.split(': ') turns it into ["Form submitted by {user.display_name}:"], because the string doesn't have : inside it to split by. Now you have a list with just one element (the original string, content_lines[0])
then, you try to get the second element of this list (by using the [1] index), which errors

#

i'm not entirely sure what you're trying to do here (or how you're trying to parse the message) so i can't actually tell you how to fix it

spring hemlock
#

itsa discrod form

#

and basially this is to go around and fix the 2000 message limit

iron eagle
#

why don't you use discord's modals? they provide a better UX and you don't have to parse messages

spring hemlock
#

i like the hard way LMAO

#

 
user_id_line = content_lines[0]
user_id = int(user_id_line.split('(ID: ')[1].split(')')[0])

#

?

covert groveBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.