[Python] Out of range error (tuple) slash commands Discum

Discussão em 'Python' iniciado por Stack, Julho 3, 2025.

  1. Stack

    Stack Membro Participativo

    cannot manage to fix out the code below which triggers me an tuple at line 22 which is the SlashCommander part. Even tried to look it up on slash.py to no avail.

    If anyone has any idea. I tried many fixes to no success, most I would get is an key error at this point. Am confused.

    This is a version from end 2023, did try to downgrade discum twice, even change python's version twice, nothing. I really have no clue at this point, it throws me an tuple error, thought it could've been the embeds index but apparently not.

    from discum.utils.slash import SlashCommander
    from discum.utils.button import Buttoner
    import time
    import random
    from threading import Lock

    bot = discum.Client(token='YOUR_TOKEN_HERE', log=False)

    guildID = "YOUR_GUILD_ID_HERE"
    channelID = "YOUR_CHANNEL_ID_HERE"
    botID = "706183309943767112" # Camelot's userid

    lock = Lock()

    def send_command(resp):
    if resp.event.guild_application_commands_updated:
    bot.gateway.removeCommand(send_command)
    slashCmds = resp.parsed.auto()['application_commands']
    s = SlashCommander(slashCmds, application_id=botID)
    temp = s.get(['dungeon'], inputs={"floor":"40"}) # Change this number to change the floor to automate
    bot.triggerSlashCommand(botID, channelID, guildID, data=temp)
    print("attempting to summon mob")

    @bot.gateway.command
    def kill(resp):
    lock.acquire()

    if resp.event.ready_supplemental:
    bot.gateway.request.searchSlashCommands(guild_id=guildID, limit=50)
    print("ready")

    if resp.event.message or resp.event.message_updated:
    data = resp.parsed.auto()
    try:
    if data.get("webhook_id") == botID and data["interaction"]["user"]["id"] == bot.gateway.session.user["id"]:
    embeds = data["embeds"]
    if len(embeds) == 0:
    print(data.get("content"))

    if "to enter the code" in data.get("content"):
    print("captcha has appeared")
    input("press enter to continue...") # You could automatically solve the captcha, but you'd have to modify the code quite a lot
    bot.gateway.close()

    elif "You already have a run in progress" in data.get("content"):
    print("we didn't kill last, sleepy time...")
    time.sleep(60)
    bot.gateway.close()

    elif len(data.get("content")) > 0:
    print("unknown message, closing down...")
    bot.gateway.close()
    else:
    if "Dungeon Floor" in embeds[0].get("title") and not "won" in embeds[0].get("description"):
    buttons = Buttoner(data["components"])

    # ATK, DEF, ABILITY, SKILL, SKIP
    combo = ['ATK','ATK', 'ATK', 'ATK', 'ATK'] # The button order to click
    previous_cmd = None

    for cmd in combo:
    time.sleep(int(random.uniform(3,7))) # The delay before clicking any buttons
    bot.click(data["webhook_id"],
    channelID=data["channel_id"],
    guildID=data.get("guild_id"),
    messageID=data["id"],
    messageFlags=data["flags"],
    data=buttons.getButton(customID=cmd),
    sessionID=bot.gateway.session_id)

    # this will automatically send an attack after you've cast "skill" (class skill),
    # feel free to modify to your needs if you don't need this.
    if cmd == 'SKILL' and previous_cmd != 'SKILL':
    time.sleep(2)
    bot.click(data["webhook_id"],
    channelID=data["channel_id"],
    guildID=data.get("guild_id"),
    messageID=data["id"],
    messageFlags=data["flags"],
    data=buttons.getButton(customID='ATK'),
    sessionID=bot.gateway.session_id)
    previous_cmd = cmd
    bot.gateway.close()
    except: pass
    lock.release()

    bot.gateway.command({"function":send_command, "params":{}})
    bot.gateway.run()

    Continue reading...

Compartilhe esta Página