vivinano / MudaeAutoBot

python bot that uses strictly the **Discord API** to Roll,Claim,and Kakera Snipe in Mudae. 5/10/21 project converted over to discum library
Apache License 2.0
143 stars 47 forks source link

Discord buttons #154

Closed HentaiRyuu closed 2 years ago

HentaiRyuu commented 2 years ago

Mudae just update this. TL;DR it change reaction to buttons (but u still can use reaction to claim things)

About Update

$togglebuttons, admin command to replace reactions by buttons in your server. Discord highly encourages all bots to replace reactions by buttons. Contrary to reactions, buttons don't have a delay when they are added. If you still don't see buttons at all or have issues to click them, your Discord app may have not been updated for a year.

$togglebuttons has the following effects:

If a roll doesn't have a button, you can still react manually with an emoji to claim the character. If it has a button, you can only click on the button. In the future, $togglebuttons will be activated by default and pikaleft/pikaright reactions will be replaced by buttons. The cooldown between two $togglereact and $perstogglereact are temporarily disabled so you can test at will these command for buttons.

vivinano commented 2 years ago

I did a implementation for buttons since it will be default in future implementations of mudae bots Currently as of writing this reply I've only added support for sniping. Will be adding support for kakera sniping in a later version hopefully

Qearlax commented 2 years ago

Hello we enabled buttons in the server but when a kakera rolled bots don't claim the kakera in other words they do nothing I updated and downloaded the latest version what should I do i just disabled the buttons for now

vivinano commented 2 years ago

Well I only added support for sniping and not kakera sniping like I stated previously.

Just give me some Images of what kakera look like as buttons and I'll see what I can do

Qearlax commented 2 years ago

image Sure kakera buttons looks like this

vivinano commented 2 years ago

I think it would be the same code for reaction sniping but i feel like this will be another chunk of repetitive code as it would be the same logic as reaction sniping

ghost commented 2 years ago

Not sure if the code added to snipe characters with buttons is working or not. Had someone else's wish come up with a button during their rolls and the bot didn't grab it even though it was on the list of characters to grab. The bot log showed attempting to snipe, but as far as I can tell it never clicked the button. Someone else claimed it after a couple sec. Snipe protection is off and my delay is set to 1 sec.

vivinano commented 2 years ago

Example?

ghost commented 2 years ago

This is what was in the log (channel/server IDs edited out):

Someone else rolled in 1234567812345678
Someone else rolled in 1234567812345678
Someone else rolled in 1234567812345678
2022-04-07 16:47:10,412:Balto appeared attempting to Snipe Server id:789012347890
Someone else rolled in 1234567812345678
Someone else rolled in 1234567812345678
Someone else rolled in 1234567812345678
Someone else rolled in 1234567812345678

This is how it looked the 2nd time, when I was rolling and it was on my wishlist:

Our user rolled in 1234567812345678
Our user rolled in 1234567812345678
2022-04-07 20:15:12,199:Wished Ein from Cowboy Bebop with 0 Value in Server id:789012347890
2022-04-07 20:15:12,910:Ein appeared attempting to Snipe Server id:789012347890
2022-04-07 20:15:17,478:Please enable $rollsleft 0 feature to prevent overrolling
True: Waifu rolling : 1234567812345678

That 2nd time I waited a few seconds and it never claimed it. I ended up clicking the button myself in Discord to claim it.

The bot successfully claims things in the character list from the settings file almost instantly as long as they are not on someone's wishlist (so it's a reaction instead of a button). If they are on someone's wishlist, then there is a button and the claim does not appear to be successful.

vivinano commented 2 years ago

image

so this is how the logic works is the button a kakera button ?

ghost commented 2 years ago

No, the buttons were a heart and a sparkle heart. IMG_20220408_001407 IMG_20220408_001451

vivinano commented 2 years ago

ah i think i know what happened sparkle heart and heart dont have a emoji name so i think that is the issue uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh trying to think how I would test something like that as i was using wleft and wright as test examples which are custom emojis

vivinano commented 2 years ago

image

i guess uncomment the if and the line after that and someone print me the results of that dataset so i can correctly code for it

vivinano commented 2 years ago

image

I test it and it works

image

vivinano commented 2 years ago

if emojiid != None and emoji.lower() in KakeraVari: sendEmoji = emoji + ":" +emojiid react_m = bot.getMessage(rchannelid, rmessageid).json()[0]['embeds'][0]

            cooldown = kakera_wall.get(rguildid,0) - time.time()
            if cooldown <= 1:
                logger.info(f"{emoji} was detected on {react_m['author']['name']}:{get_serial(react_m['description'])} in Server: {rguildid}")
                time.sleep(snipe_delay)
                bot.addReaction(rchannelid,rmessageid,sendEmoji)
            else:
                logger.info(f"Skipped {emoji} found on {react_m['author']['name']}:{get_serial(react_m['description'])} in Server: {rguildid}")
                return 

            warn_check = mudae_warning(rchannelid)
            kakerawallwait = wait_for(bot,lambda r: warn_check(r) and 'kakera' in r.parsed.auto()['content'],timeout=5)

            if kakerawallwait != None:
                time_to_wait = waitk_finder.findall(kakerawallwait['content'])
            else:
                time_to_wait = []

            if len(time_to_wait):
                timegetter = (int(time_to_wait[0][0] or "0")*60+int(time_to_wait[0][1] or "0"))*60
                print(f"{timegetter} for kakera_wall was set for Server : {rguildid}")
                kakera_wall[rguildid] = timegetter + time.time()`

if anyone wants to convert that code into a function and add it into the message handler than kakera will be enabled

ghost commented 2 years ago

I still can't get the actual button clicking to work for sniping. I turned on buttons under all my rolls to test. I added "not" before "in" on Line 514. This should make the script parse the very next roll I do as a character I wished (unless it's actually a character I wished). The log indicates it did so, yet it did not press the button after over a minute. Delay is set to 1 in settings, server has no snipe protection enabled. It seems like there might be an issue in the snipe_intent function, but I can't figure out what it would be.

Our user rolled in 9##############
2022-04-08 01:17:00,587:Wished Faker (OG) from OverGeared with 0 Value in Server id:7###################

image

vivinano commented 2 years ago

image image

still working for me did you update discum because older version of discum don't have button support

ghost commented 2 years ago

Using Python 3.10 and Discum 1.4.0. I uninstalled Windows Store python and installed directly from their site just in case that was a problem. I cannot for the life of me get the function to click the reaction to work. It's definitely getting to that part in the code, it's just not successfully clicking the button

I re-downloaded the repo and only added my token, channel ID, channel ID again, and server ID to the settings file. Then in the script I added the "not" to make it react to every roll. It still doesn't click the button, so I'm not sure what's going on with it.

vivinano commented 2 years ago

hmm I can't fix what I can't see on my end its clicking for me so I think this would classify as a python environment issue which is pretty much hard for me to locate the problem without actually deep diving into your personal computer

ghost commented 2 years ago

I think I just got it to work - and sorry for wasting your time, it was indeed an envrionment issue. I had installed discum via 'pip install discum' both times. I just tried to install it from their github using the command they recommend on their page. Now it's working! Not sure what the difference between the 1.4.0 I got via the 'pip install discum' command is and the 1.4.0 I got from their Github page is, but that appears to have been the issue. It is clicking the button now.

Again, sorry for all the back and forth on this. Can't believe that was the solution

Qearlax commented 2 years ago

It happened for me as well but just for slash rolling I installed git bash and installed discum over there and everything fixed all of a sudden.

vivinano commented 2 years ago

Ah it's no problem generally the more people that actively take part in discussion means their still interest in the app I made so small victories. Feels like a challenge anytime the mudae dev makes a change to his application and in return I make changes to accommodate xD

My ultimate master goal is to break mudae thru the amount of request coming from selfbots 🤫🤫🤫 But you guys never seen this comment it's a secret that will eventually be buried in the comment thread 🤫🤫🤫

YandereMyName commented 2 years ago

I will uncomment code after, if buttons (line 452) but, he is not clamed char