0

I'm trying to do autoclick on button in DM's using discum. My actual code:

import discum
bot = discum.Client(token='token')
from discum.utils.button import Buttoner

@bot.gateway.command
def message_data(resp):
    if resp.event.message:
        m = resp.parsed.auto() 
        channelID = m['channel_id']
        messageID = m['id']
        message = bot.getMessage(channelID, messageID)
        data = message.json()[0]
        buts = Buttoner(data["components"])
        bot.click(
            data["author"]["id"],
            channelID=data["channel_id"],
            messageID=data["id"],
            messageFlags=data["flags"],
            data=buts.getButton("First"),
        )

bot.gateway.run()

It should work but... Nope. Maybe I'm stupid, if you can - please help me!

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 22 '22 at 12:59

1 Answers1

0

Using Buttoner I don't think you should be converting your data variable to json, could be what is causing your issue, try checking your terminal for an actual error message -> which would help you in identifying the issue. Try passing your params to buttoner using your default message object without any conversions as so:

buts = Buttoner(m["components"])
bot.click(
    m["author"]["id"],
    channelID=m["channel_id"],
    guildID = m['guild_id'] if 'guild_id' in m else None,
    messageID=m["id"],
    messageFlags=m["flags"],
    data=buts.getButton(row=0, column=0),
    sessionID=ses,
)

Additionally note that Discord button events now require a sessionID as well to be passed (to Buttoner). You cannot send click events without a session ID (funnily enough it is not currently checked by Discord so it doesn't need to be valid at all). The last parameter above depicts its usage. Your real session ID can be found in various ways depending on your API wrapper you are using. (You can also get it from your browser's dev tools in session storage) But I think that if you are wanting to make a bot for testing something or a quick project you may still use any random string as your sessionID.

geostima
  • 325
  • 2
  • 18