#๐Ÿ”’ TypeError: __init__() takes 4 positional arguments but 5 were given

113 messages ยท Page 1 of 1 (latest)

lavish marlinBOT
#

@ionic ingot

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.

ionic ingot
#

?pastebin

#
2024-08-31 20:28:11 INFO     discord.client logging in using static token
2024-08-31 20:28:13 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 1ebb790c1e6112bab81f095286a88da9).
Commands have been re-synced.
We have logged in
2024-08-31 20:28:52 ERROR    discord.ui.view Ignoring exception in view <ApprovalView timeout=180.0 children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Reject' emoji=None row=None sku_id=None>
Traceback (most recent call last):
  File "/Users/calvinsupasanya/Library/Python/3.9/lib/python/site-packages/discord/ui/view.py", line 430, in _scheduled_task
    await item.callback(interaction)
  File "/Users/calvinsupasanya/Desktop/Coding/Project/YUGEN Accountant/main.py", line 862, in reject
    modal = RejectionReasonModal(self.db, self.order, self.transaction, interaction.user.id)
TypeError: __init__() takes 4 positional arguments but 5 were given
#

that's the error code

#

and this is the /paid command section

#

and I honestly don't know anymore

#

I don't see what's wrong man

restive swift
#

the error doesn't make sense with that code, no

#

in particular that error you would have for a class whose init took self + 3 args

ionic ingot
restive swift
#

seems like you must be calling something other than that class definition in the code you shared

ionic ingot
#

I didn't even provide 5 arguements in the modal variable

#

it was four

#

what is it complaining about

sinful kelp
#

my only guess is that you re-define RejectionReasonModal somewhere later, from this code this error doesnt really make sense

opaque folio
ionic ingot
#

how would that help thoughhhhh

opaque folio
ionic ingot
#

ok hold on

opaque folio
#

If it still errors out, can you share the full script please?

#

Not partially

ionic ingot
#

but I'm just gonna replace my bot token

green river
opaque folio
ionic ingot
#
2024-08-31 21:11:04 ERROR    discord.ui.view Ignoring exception in view <ApprovalView timeout=180.0 children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Reject' emoji=None row=None sku_id=None>
Traceback (most recent call last):
  File "/Users/calvinsupasanya/Library/Python/3.9/lib/python/site-packages/discord/ui/view.py", line 430, in _scheduled_task
    await item.callback(interaction)
  File "/Users/calvinsupasanya/Desktop/Coding/Project/YUGEN Accountant/main.py", line 863, in reject
    modal = RejectionReasonModal(
TypeError: __init__() got an unexpected keyword argument 'transaction'
#

!paste

lavish marlinBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

ionic ingot
ionic ingot
opaque folio
#

like it recognizes, db and order but errors at transaction

sinful kelp
#

this is still not the full code. i dont think Modal.__init_subclass__ does anything too weird so im still left with my only guess

opaque folio
# ionic ingot ?

Are you sure you do not have another class called RejectReasonModal before the paid command?

ionic ingot
#

and I'm gonna send the full script

#

just let me try fixing that error first

#

and if we really can't

#

I'll send the full script

#

wraning though

#

it's more than a thousand fivehundred lines

daring delta
#

Well, we aren't going to read all thousand and fivehundred lines, but we can trace where the problem is easier when we can see the full picture.

ionic ingot
#

@lavish marlin thank u pookie

ionic ingot
sinful kelp
#

"thousand fivehundred" is 1500, how do you have 1500 lines take more than 512 kb? do you have lines larger than 350 chars each? that doesnt make sense

daring delta
#

Create multiple pastes. Half in one, half in the other.

green river
ionic ingot
#

to be honest I don't know but hold on

#

let me try to fix this issue myself once more

restive swift
#

if this is relying on some hot-reloading of code maybe something isn't being reloaded correctly

ionic ingot
#

uhhhh sooo

#

this is the ORIGINAL version of the /paid section of the code

#
2024-08-31 21:27:50 INFO     discord.client logging in using static token
2024-08-31 21:27:52 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: a36711715662091d7eb3a03d79e57c54).
Commands have been re-synced.
We have logged in
2024-08-31 21:28:46 ERROR    discord.ui.view Ignoring exception in view <ApprovalView timeout=180.0 children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Reject' emoji=None row=None sku_id=None>
Traceback (most recent call last):
  File "/Users/calvinsupasanya/Library/Python/3.9/lib/python/site-packages/discord/ui/view.py", line 430, in _scheduled_task
    await item.callback(interaction)
  File "/Users/calvinsupasanya/Desktop/Coding/Project/YUGEN Accountant/main.py", line 862, in reject
    modal = RejectionReasonModal(self.db, self.order, self.transaction, interaction.user.id, self.original_channel_id)
TypeError: __init__() takes 4 positional arguments but 6 were given
#

and this is the error message

opaque folio
ionic ingot
#

please don't hate me

#

!paste

lavish marlinBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

ionic ingot
#

THERE

#

THERE

#

THERE

#

WHOLE CODE

sinful kelp
#

you redefine RejectionReasonModal on line 1084

opaque folio
#

Why do you have another class of the same name at line 1084?

ionic ingot
#

ah

#

becuase

#

chatGPT created for me

#

QQQQ

sinful kelp
#

not exactly surprised, if you wrote this by yourself you'd find this error right away

daring delta
#

And that is why it's important to share all yourgpt code, not just what you think is important.

ionic ingot
#

I"M SORRY GUYS

#

FOORGIVE ME

ionic ingot
#

brother

opaque folio
#

You only need one unique class that should be handled in both situations

ionic ingot
#

or can I rename the other class on 1084?

opaque folio
#

sure

ionic ingot
#

@opaque folio

#

I

#

yo

#

@opaque folio @sinful kelp lambda and agent

#

I will virtually send u my dearest and sincerest thanks

#

to you

#

god bless

#

you

#

I love you

#

let me kiss u

#

@opaque folio

#

@opaque folio

#
2024-08-31 21:50:41 INFO     discord.client logging in using static token
2024-08-31 21:50:43 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 9524971538d541dd0483a6c271cfeb9b).
Commands have been re-synced.
We have logged in
2024-08-31 21:51:46 ERROR    discord.ui.modal Ignoring exception in modal <RejectionReasonModal timeout=None children=1>:
Traceback (most recent call last):
  File "/Users/calvinsupasanya/Library/Python/3.9/lib/python/site-packages/discord/ui/modal.py", line 189, in _scheduled_task
    await self.on_submit(interaction)
  File "/Users/calvinsupasanya/Desktop/Coding/Project/YUGEN Accountant/main.py", line 915, in on_submit
    await interaction.response.edit_message(embed=embed, view=self.disable_buttons())
  File "/Users/calvinsupasanya/Library/Python/3.9/lib/python/site-packages/discord/interactions.py", line 990, in edit_message
    await adapter.create_interaction_response(
  File "/Users/calvinsupasanya/Library/Python/3.9/lib/python/site-packages/discord/webhook/async_.py", line 223, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.0.components.0: Value of field "type" must be one of (2, 3, 5, 6, 7, 8).
#

WE GOT ANOTHER ISSUE

#

!paste

lavish marlinBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

ionic ingot
#

that's the current /paid command section

lavish marlinBOT
#
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.