Hi
I have a chatbot with my own account and i am trying to create a timeout command. My bot has all needed scopes. For testing i want a “$v” command that will timeout the user for one second. i have tried different things like using “https://api.twitch.tv/helix/moderation/bans” as URL and other formats for the json data like:
json_data = {
'data': {
'user_id': user_id,
'duration': duration,
'reason': reason
}
}
Here is my last attempt:
@commands.command(name='v')
async def vanish(self, ctx):
broadcaster_id = "my_actual_ID"
moderator_id = "my_actual_ID"
user_id = ctx.author.id
duration = 1
reason = "Vanish command"
headers = {
"Client-Id": os.getenv('MY_CLIENT_ID'),
"Authorization": f "Bearer {os.getenv('MY_ACCESS_TOKEN')}",
"Content-Type": "application/json"
}
url = f "https://api.twitch.tv/helix/moderation/bans?broadcaster_id={broadcaster_id}&moderator_id={broadcaster_id}"
payload = {
"user_id": user_id,
"duration": duration,
"reason": reason
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 204:
await ctx.send(f"{ctx.author.name} is gone. Poof!")
else:
print(response.text)
await ctx.send("There was a problem executing the command.")
I must be overlooking something or not understanding it enough. According to prints it sends the correct user_id but I still get the message: {“error”: “Bad Request”, “status”:400, “message”: “Missing required parameter "user_id"”}
Can anyone help me?