Skip to content

Issue with the lib handling the response from the edit #383

@ghost

Description

broadcaster = client.create_user(CHANNEL_ID, 'CHANNEL_NAME')


async def edit_reward(title: str, paused: bool, cost: int):
    main_reward = (await broadcaster.get_custom_rewards(token=USER_OAUTH_TOKEN, only_manageable=True))[0]
    await main_reward.edit(token=USER_OAUTH_TOKEN, title=title, paused=paused, cost=cost, max_per_user_per_stream=None)

async def main():
    await edit_reward(title='TEST', paused=False, cost=10)
    await client.start()

client.loop.run_until_complete(main())

So the code seems like working, but when i call

await edit_reward(title='TEST', paused=False, cost=10)

It updates the reward and then throws TypeError:

Traceback (most recent call last):
File "c:\Users\user\Downloads\twitch_bot\twitch_bot.py", line 119, in
client.loop.run_until_complete(main())
File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "c:\Users\user\Downloads\twitch_bot\twitch_bot.py", line 100, in main
print(await edit_reward(title='TEST', paused=True, cost=10))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\user\Downloads\twitch_bot\twitch_bot.py", line 34, in edit_reward
await main_reward.edit(token=USER_OAUTH_TOKEN, title=title, paused=paused, cost=cost, max_per_user_per_stream=None)
File "C:\Program Files\Python311\Lib\site-packages\twitchio\rewards.py", line 239, in edit
for reward in data["data"]: ~~~~^^^^^^^^
TypeError: list indices must be integers or slices, not str

Metadata

Metadata

Assignees

Labels

2.0TwitchIO 2.0Confirmed BugBug has been confirmedHTTPHTTP Endpoint related items.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions