diff --git a/discord/interactions.go b/discord/interactions.go index d2b61fe..35088ee 100644 --- a/discord/interactions.go +++ b/discord/interactions.go @@ -60,6 +60,18 @@ func (client *Client) sendRequest(url string, payload map[string]interface{}) er return err } +func (client *Client) SendChatMessage(content string) error { + interactionsUrl := fmt.Sprintf("https://discord.com/api/v9/channels/%s/messages", client.ChannelID) + + payload := map[string]interface{}{ + "content": content, + "flags": 0, + "tts": false, + } + + return client.sendRequest(interactionsUrl, payload) +} + func (client *Client) SendCommand(commandName string, options map[string]string) error { sessionID, err := client.safeGetSessionID() if err != nil { diff --git a/instance/emojis.json b/instance/emojis.json new file mode 100644 index 0000000..53605c0 --- /dev/null +++ b/instance/emojis.json @@ -0,0 +1,386 @@ +{ + "1168411408325672991": "Ahuitzotl", + "1264283654755057714": "Amethyst Hoopfish", + "1183094353762205798": "Arapaima", + "1175888405322805319": "Arctic Char", + "1113389063001616396": "Aspidochelone", + "1110527407934418954": "Barracuda", + "1109186607120130049": "Bass", + "1175888406832746566": "Beluga Whale", + "1266856989162602608": "Black Neontetra", + "1266856937211957349": "Bloodfin Neontetra", + "1221076511210340413": "Blue Tang", + "1109207286909517834": "Bluegill", + "1174910072023961700": "Box Turtle", + "1260027031010414592": "Boxfish", + "1174910103753850913": "Bullfrog", + "1178677279698718750": "Bunyip", + "970794371869995058": "Butterfly Fish", + "1151812947010670692": "Catfish", + "1111764149786120195": "Charybdis", + "1260027094814036068": "Clown Loach", + "1111363785274441832": "Cod", + "1183094548533096619": "Coelacanth", + "1264283656067878912": "Colorful Hoopfish", + "1262537716881424496": "Colorful Leech", + "1151504745316499519": "Crappie", + "1112017991253630996": "Crayfish", + "1282003338082123959": "Crispfin", + "1282003346101764146": "Demonfish", + "1319850183663681616": "Desolate Yetifish", + "1264283336549994671": "Diamond Hoopfish", + "1284851946565406872": "Draethar", + "1111745593405100093": "Electric Eel", + "1282003340099719188": "Fleshbiter", + "1282003333162471424": "Fleshfish", + "1157404684043165756": "Flounder", + "1111807929738342453": "Flying Fish", + "1282003344331767849": "Fodderfeed", + "1282003343312420906": "Forktail Biter", + "1155808322214187099": "Ghost Fish", + "1110527391954124832": "Giant Squid", + "1266856966966480896": "Glowlight Neontetra", + "1157186816844243014": "Golden Dorado", + "1264283335325253703": "Golden Hoopfish", + "1154308949722529832": "Goldfish", + "1160324742587363329": "Gorgolox", + "1266856977615818784": "Green Neontetra", + "1319850204224028745": "Gronchfish", + "1151705822343200848": "Guppy", + "1111457207993770014": "Hammerhead Shark", + "1308906823704903831": "Insane Fish", + "1175888398402211880": "Issrakr", + "971160094349869126": "Jellyfish", + "1111558459813531669": "Jormungandr", + "1221076500405817384": "Kathzilla", + "1112742616216371202": "Koi", + "1054468271841214566": "Kraken", + "1174910052516233266": "Leafy Sea Dragon", + "1110260339334983710": "Leviathan", + "1221076507305316363": "Lionfish", + "1221076502377009223": "Lusca", + "1111382991713865728": "Mahi Mahi", + "1260027053835681893": "Mandarinfish", + "1110215549637644410": "Marlin", + "1264283657376497815": "Megalodon", + "1111645414802870372": "Minnow", + "1175888408573399040": "Narwhal", + "1175888402147717281": "Nelma", + "1266856954794606694": "Neontetra", + "1183094475527028736": "Ocean Sunfish", + "1262786202730500138": "Ogua", + "1262537715354964020": "Oscar", + "1221076514498547722": "Parrotfish", + "1266856862909857923": "Pearl Danio", + "1262538120423936140": "Peters's Elephant-Nose Fish", + "1262537718555213935": "Pink Leech", + "1113065355649220639": "Piranha", + "1175888400641970377": "Pliosaur", + "1111710037228920953": "Pufferfish", + "1260027069648338975": "Purple Tang", + "1110260295781318696": "Rainbow Bass", + "1308906851714207766": "Rainbow Fish", + "971151079096061962": "Red Arowana", + "1262538110219194390": "Redbreast Sunfish", + "1262538113293484052": "Roundnose Grenadier", + "1264283651882090588": "Ruby Hoopfish", + "1262538119144804523": "Sablefish", + "1221076504843390976": "Sailfish", + "1109260042005397574": "Salmon", + "1264283653328863253": "Sapphire Hoopfish", + "1110639618031886386": "Sardine", + "1168411410141818911": "Scylla", + "1308906839173238886": "Seaman Fish", + "1262537711999520862": "Shad", + "1110966108841852928": "Shrimp", + "1150777832977469521": "Skeleton Fish", + "1262538117538381834": "Smooth Oreo", + "1151886763560804522": "Starfish", + "991732639348293663": "A Plus", + "1092733218387656754": "Adventure Compass", + "934112100970807336": "Adventure Ticket", + "1007023088493400084": "Adventure Voucher", + "936688654531825764": "Aetheryx' Flower", + "1090925229313900544": "Aha's Pitcher Plant", + "960656161479209040": "Aiphey's Gemstone", + "984501149501653082": "Alcohol", + "933475704434196540": "Alien Sample", + "976514724336402462": "Ammo", + "864220608865763378": "Ant", + "873172443462791200": "Anti-Rob Pack", + "887000049266069575": "Apple", + "928417989357891675": "Apron", + "926267869258457139": "Armpit Hair", + "937502609550503936": "Baby", + "869294028385038354": "Badosz's Card", + "1154740654375698523": "Bait Box", + "979435284603215932": "Ban Hammer", + "830509316888985621": "Bank Note", + "998740316565807124": "Barrel of Sludge", + "980475704414187590": "Beaker of sus fluid", + "905951197821800500": "Bean", + "922652278308093952": "Bean Mp3 Player", + "1050571150985543710": "Bean Seeds", + "1012476827496894534": "Beggars Bowl", + "890365752534761472": "Berries and Cream", + "1288207560582758591": "Big Brain", + "910648334212026498": "Binary", + "1057761253067587694": "Birthday Cake", + "932395505382744106": "Black Hole", + "933188762782011454": "Blob", + "975398146249207808": "Blue Plastic Bits", + "931691006754189342": "Blue's Plane", + "1166914487664779305": "Boar", + "978074542683611136": "Bolt Cutters", + "978747427983085700": "Bottle of Whiskey", + "1004915442818756778": "Box Box", + "830509316901175366": "Box of Sand", + "936271905357459508": "Boxed Chocolates", + "1039283716960309288": "Broccoli", + "998341356034478241": "Broccoli Seeds", + "977726388150894653": "Bundle Box", + "944679123962454046": "Cactus", + "1088338480112873472": "Caipirinha", + "903730591294439496": "Camera", + "943637574906417214": "Candy", + "1024829646287683626": "Candy Cane", + "1024830960216313969": "Candy Corn", + "1039250395647713382": "Carrot", + "998015510992130068": "Carrot Seeds", + "830509316632346625": "Cell Phone", + "1226163164052455454": "Chads's Weights", + "1225838120843345951": "Chet's USB", + "943292242523725855": "Chill Pill", + "998339184139968552": "Chocolate Cake", + "921193372868309034": "Christmas Gift", + "923011690126254170": "Christmas Tree", + "942168959346704435": "Coin Bomb", + "1228761965392953394": "Coin Nuke", + "1013966592352202834": "Coin Voucher", + "1288207558351392811": "Cooked Eggs", + "981318260463136778": "Cookie", + "996880154318090290": "Corn Seeds", + "972246926303051776": "Corncob", + "973632646703894588": "Corndog", + "950859370474922094": "Cowboy Boots", + "944662489784782859": "Cowboy Hat", + "892546328406663168": "Credit Card", + "976607098588790804": "Crunchy Taco", + "1228786564956557372": "Crypto Scam Coin", + "976612203211931678": "Cupid's Big Toe", + "933194488241864704": "Cursed Pepe", + "1289651018908565555": "D100", + "861390900219478037": "Daily Box", + "861390901049425950": "Dank Box", + "1225815201073598464": "Dank Memer's Hard Drive", + "1167617729222684692": "Deer", + "1230865724072005672": "Delta 9", + "1230865725992996906": "Delta 9 Roll", + "1230865725166452836": "Delta 9 Seeds", + "1021543611583709224": "Designer Hoodie", + "975470580381921310": "Developer Box", + "1291936484672147547": "Devil's Horn", + "956197809114189846": "Diamond", + "1033102634367856722": "Digging Trophy", + "1167650839473696781": "Dragon", + "1167694678905339975": "Duck", + "903663686017749013": "Duct Tape", + "975768694435233842": "Ectoplasm", + "1116488145182142464": "Electrifying Zing", + "1034512523141058580": "Elf On The Shelf", + "1291033458432409621": "Embalming Fluid", + "924808588420059207": "Empowered Fart Bottle", + "931295850292989973": "Enchanted Badosz's Card", + "989307051945648178": "Energy Drink", + "862369027984064552": "Engagement Ring", + "1107672694545195060": "Exclusive Gems Box", + "966338245443080213": "Fake ID", + "860285654009511936": "Fart In A Bottle", + "1008145204450168972": "Fertilizer Bag", + "873970101479686194": "Fidget Spinner", + "1116868661903364206": "Fierce Fang Fare", + "1225911028886274048": "Figure's Watch", + "1031942551508369449": "Fishing Trophy", + "960588198331957278": "Fool's Notif", + "921790077393338378": "Fossil", + "1204797994470346784": "Freemium Ad", + "980955203018821632": "Fresh Bread", + "987156741110255716": "Friend's Gift", + "935631382590394398": "Garbage", + "987157087693975612": "Gift Box", + "1129349754099347466": "God Box", + "979094753763270656": "Golden Coins", + "987046202212237392": "Golden Corndog", + "945419831535083570": "Golden Nugget", + "975398146416971907": "Golden Plastic Bits", + "1009956477814968360": "Grass", + "1029829993301291059": "Gravestone", + "904821937807716352": "Green Screen", + "873172443685064744": "Grind Pack", + "1118472258562818119": "Grub Pail", + "976128238109736970": "Hardhat", + "1294115048922415143": "Haunted Box", + "904886213087989761": "Headphones", + "1008113090472181760": "Hoe", + "920812196567597067": "Holiday Stocking", + "1010341373154689164": "Holy Badosz's Bread", + "1010314176511627344": "Holy Water", + "868286178070261760": "Hunting Rifle", + "1033008418870546522": "Hunting Trophy", + "1119414774560718898": "Inflated Delicacy", + "968850393431961630": "Jacky o' Lanty", + "932759942081941515": "Jar Of Singularity", + "1186704670559830086": "Joke Book", + "981272956351156234": "Junk", + "969374516205719592": "Kable's Sunglasses", + "904821868312268850": "Keyboard", + "863198415822389268": "Ladybug", + "887000049354145792": "Landmine", + "830509316674813974": "Laptop", + "950807315915870279": "Lasso", + "976890603772186624": "Law Degree", + "957698195000025158": "Legacy Common Fish", + "970794371869995058": "Legacy Exotic Fish", + "992184511674728501": "Legacy Fishing Bait", + "868519722780598323": "Legacy Fishing Pole", + "971160094349869126": "Legacy Jelly Fish", + "860228238956429313": "Legacy Kraken", + "971430841211322408": "Legacy Legendary Fish", + "971151079096061962": "Legacy Rare Fish", + "935147848977219635": "Life Saver", + "991768633611141200": "Like Button", + "923005301421113344": "Literally a Tree", + "860196324762452028": "Literally Karen", + "1064912408629493861": "Lotus Flower", + "1064912414430220388": "Lotus Seeds", + "986396363707281468": "Lucky Horseshoe", + "1225823845957763133": "Margaux's Doll", + "999771598989041794": "Melmsie's Banana", + "1036723929437437972": "Melmsie's Beard", + "1153951318076043264": "Membership Box", + "1153951321565704223": "Membership Pack", + "861390901300953118": "Meme Box", + "1036708618801795092": "Meme pills", + "1033858319774912612": "Menorah", + "1223512579800956969": "Meridian's Croc", + "1173120113839452290": "Message In a Bottle", + "1223727851728011415": "Metal Pipe", + "932047375579643944": "Meteorite", + "903784794398294036": "Microphone", + "1181277935051755591": "Mistletoe", + "1022972147175526441": "Mole Man", + "980515661619003482": "Motivational Poster", + "904821818425241600": "Mouse", + "975398148660928602": "Multi Colored Plastic Bits", + "910673407761317928": "Musical Note", + "873172443529891871": "New Player Pack", + "1052244169139163219": "New Years Popper", + "861390901405679626": "Normie Box", + "993233845174415380": "Odd Eye", + "895447304805429278": "Old Box", + "946724166223138856": "Old Cowboy Revolver", + "1173120058621435995": "Old Shell", + "975398146333081690": "Orange Plastic Bits", + "921193342501539891": "Ornament", + "1006333035970576394": "Space Adventure Box", + "830509316900651059": "Padlock", + "1001266209628631071": "Pepe Box", + "942212715454271518": "Pepe Coin", + "1036669523593543832": "Pepe Crown", + "1305487098928959559": "Pepe Jug", + "948673104870252564": "Pepe Medal", + "890646381482614824": "Pepe Ribbon", + "1006984234763825263": "Pepe Ring", + "993285762697146449": "Pepe Statue", + "1040611845087694919": "Pepe Sus", + "1305487084492161044": "Pepe Toilet", + "940712966213496842": "Pepe Trophy", + "1228728840856146032": "Pepe's Bathwater", + "936381028396847195": "Pet Collar", + "1042189238059421747": "Pet Feces", + "1186720980631031868": "Pet Feeder", + "1042170125777915914": "Pet Food", + "946176458865405982": "Pet Saddle", + "975398146152738906": "Pink Plastic Bits (Deprecated)", + "1120348221202501702": "Pink Rubber Ducky", + "1127334051422937240": "Pink Sludge Monster", + "1220132326999195770": "Pirate Hat", + "1225064802733391912": "Pixel Trophy", + "940735144849985596": "Pizza Slice", + "1076072434144391180": "Plastic Bag", + "1003453280438988900": "Plastic Box", + "979517884101459999": "Police Badge", + "1088754007834644550": "Postcard", + "1053437124604604436": "Potato", + "997302171110481960": "Potato Seeds", + "899772669262700615": "Prestige Coin", + "898709240837976064": "Prestige Pack", + "1113612861260955688": "Prismatic Delight", + "975398146618306630": "Purple Plastic Bits", + "1226177611936301167": "Puzzle Key", + "1166914475614539777": "Rabbit", + "968274752135368704": "Rare Butterfly", + "936007340736536626": "Rare Pepe", + "1040018182322262117": "Reversal Card", + "905501619523829780": "Ring Light", + "991364525783785512": "Robbers Mask", + "966630329756565594": "Robbers Wishlist", + "926573136558850139": "Royal Scepter", + "1087312200227631174": "Rusty Machine", + "1226146049723465749": "Samuel's Book", + "959925962412269630": "Sanic Hot Dog", + "862415055622635560": "Santa's Bag", + "921546940032880660": "Santa's Hat", + "889266191808471114": "School Urinal", + "887000050201419787": "Seaweed", + "923291410130686022": "Shooting Star", + "977969734307971132": "Shop Coupon", + "868263822035669002": "Shovel", + "830509316933943307": "Shredded Cheese", + "1210356188055605348": "Skeleton Key", + "1167673389125734471": "Skunk", + "1288207561513893971": "Smol Brain", + "992137642479190216": "Snowball", + "920796800774991932": "Snowflake", + "1113841331568128071": "Soggy Boots", + "1173120101231366144": "Soggy Plant Clump", + "905572838847684648": "Sound Card", + "864261394944884746": "Spider", + "1024829726159798272": "Spooky Mask", + "927305405988753468": "Squishy Paw", + "862774540895125584": "Stack of Cash", + "923291410323603457": "Star Fragment", + "864568819795755038": "Stickbug", + "1092342005843103805": "Stolen Amulet", + "1021197723212455956": "Stonk Coin", + "990673255457239070": "Stonk Machine", + "1074946229856895027": "Strawberry Shake", + "921501533273751682": "Streak Freeze", + "894597638161326091": "Sugar Skull", + "1138817151654965319": "Sunbear's D20", + "1113840705761185892": "Sunken Treasure", + "1116488130514665653": "Tentacled Temptation", + "926522932560269413": "The Letter", + "1000515380286083104": "The Megaphone", + "1225815199131500646": "Thrym's Leash", + "887000049740030032": "Tidepod", + "976886606680178698": "Tip Jar", + "928399081112469544": "Toilet Paper", + "1154389882551144549": "Tool Box", + "959429404541468713": "Townie's Eyes", + "986723862190383165": "Trash", + "945442853016973343": "Treasure Map", + "1033824245077262386": "Trivia Trophy", + "953310228600983612": "Tumbleweed", + "1167303857924210758": "Universe Box", + "976572178348793858": "Used Diaper", + "979145429138673744": "Vaccine", + "1024827756300750848": "Voodoo Doll", + "1087969041689362452": "Vote Pack", + "1039590274642497596": "Water Bucket", + "1008888972665172020": "Watering Can", + "1173120072668160041": "Waterlogged Log", + "1050570968063557652": "Watermelon", + "1050571042436943893": "Watermelon Seeds", + "877566903516790855": "Wedding Gift" +} \ No newline at end of file diff --git a/instance/events.go b/instance/events.go new file mode 100644 index 0000000..14745f5 --- /dev/null +++ b/instance/events.go @@ -0,0 +1,166 @@ +package instance + +import ( + _ "embed" + "encoding/json" + "fmt" + "github.com/BridgeSenseDev/Dank-Memer-Grinder/gateway" + "github.com/BridgeSenseDev/Dank-Memer-Grinder/utils" + "regexp" + "strings" + "time" +) + +//go:embed emojis.json +var emojisJson []byte + +var emojis map[string]interface{} + +func init() { + err := json.Unmarshal(emojisJson, &emojis) + if err != nil { + utils.Log(utils.Important, utils.Error, "", fmt.Sprintf("Failed to unmarshal emoji data: %v", err)) + } +} + +func (in *Instance) EventsMessageCreate(message gateway.EventMessage) { + embed := message.Embeds[0] + + if embed.Color != 16044763 { + return + } + + if embed.Title == "Trivia Night" { + re := regexp.MustCompile(`\*\*(.*?)\*\*`) + matches := re.FindStringSubmatch(embed.Description) + var ( + question string + answer string + ) + if len(matches) > 1 { + question = matches[1] + } else { + return + } + + for _, category := range trivia { + if strings.Contains(category.(string), question) { + if ans, ok := category.(map[string]interface{})[question].(string); ok { + answer = ans + } else { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Question not found in trivia data: %v", question)) + return + } + } + } + + lines := strings.Split(embed.Description, "\n") + for _, line := range lines { + line = strings.TrimSpace(strings.TrimPrefix(line, "-")) + if line == answer { + <-utils.Sleep(time.Duration(utils.Rng.Intn(5-2)+2) * time.Second) + err := in.SendChatMessage(strings.ToLower(answer), true) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to send trivia night chat message: %s", err.Error())) + return + } + } + } + } else if embed.Title == "Fortnite Attack" || embed.Title == "Dank Memer Corp" || embed.Title == "Anti-Rizz" { + re := regexp.MustCompile(`"([^"]+)"`) + match := re.FindStringSubmatch(embed.Description) + if len(match) > 1 { + <-utils.Sleep(time.Duration(utils.Rng.Intn(5-2)+2) * time.Second) + err := in.SendChatMessage(strings.ToLower(match[1]), true) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to send first to say chat message: %s", err.Error())) + } + } else { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to find first to say quote: %s", embed.Description)) + } + } else if embed.Title == "Reverse Reverse" { + if phrase := strings.TrimSpace(strings.Split(embed.Description, "#")[1]); phrase != "" { + runes := []rune(phrase) + for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 { + runes[i], runes[j] = runes[j], runes[i] + } + + <-utils.Sleep(time.Duration(utils.Rng.Intn(5-2)+2) * time.Second) + err := in.SendChatMessage(strings.ToLower(string(runes)), true) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), + fmt.Sprintf("Failed to send reverse reverse message: %s", err.Error())) + } + } + } else if embed.Title == "Dice Champs" { + err := in.ClickButton(message, 0, 0) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to click dice champs button: %s", err.Error())) + } + } else if embed.Title == "Fortnite Dance Mode" { + directions := map[string]string{ + "AR": "right", + "AL": "left", + "AU": "up", + "AD": "down", + } + + combo := strings.Split(embed.Description, "#")[1] + re := regexp.MustCompile(`<:(A[RLUD]):\d+>`) + matches := re.FindAllStringSubmatch(combo, -1) + + var result []string + for _, match := range matches { + if dir, ok := directions[match[1]]; ok { + result = append(result, dir) + } + } + + <-utils.Sleep(time.Duration(utils.Rng.Intn(5-2)+2) * time.Second) + err := in.SendChatMessage(strings.ToLower(strings.Join(result, " ")), true) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), + fmt.Sprintf("Failed to send fortnite dance message: %s", err.Error())) + } + } else if embed.Title == "Punch Pepe" { + lines := strings.Split(embed.Description, "\n") + for row := 0; row < 3; row++ { + if line := lines[row+3]; strings.Contains(line, "pepeBoxer") { + col := 0 + if strings.HasPrefix(line, "# :white_small_square::white_small_square:<:pepeBoxer") { + col = 2 + } + err := in.ClickButton(message, row, col) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), + fmt.Sprintf("Failed to click punch pepe button: %s", err.Error())) + } + break + } + } + } else if embed.Title == "Fish Guesser" || embed.Title == "Item Guesser" { + re := regexp.MustCompile(`(\d+)\.(png|gif)$`) + matches := re.FindStringSubmatch(embed.Image.URL) + + if matches == nil || len(matches) < 2 { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), + "Failed to extract image ID from URL") + return + } + + imageId := matches[1] + + imageName, ok := emojis[imageId].(string) + if !ok { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), + fmt.Sprintf("Image ID %s not found in emojis map", imageId)) + return + } + + err := in.SendChatMessage(strings.ToLower(imageName), true) + if err != nil { + utils.Log(utils.Important, utils.Error, in.SafeGetUsername(), + fmt.Sprintf("Failed to send fish guesser chat message: %s", err.Error())) + } + } +} diff --git a/instance/instance.go b/instance/instance.go index e51f90c..9952a9a 100644 --- a/instance/instance.go +++ b/instance/instance.go @@ -17,6 +17,7 @@ type Client interface { SendMessage(op gateway.Opcode, data gateway.MessageData) error Close() AddHandler(event gateway.EventType, handler interface{}) error + SendChatMessage(content string) error SendCommand(name string, options map[string]string) error SendSubCommand(name string, subCommandName string, options map[string]string) error ClickButton(message gateway.EventMessage, row int, column int) error diff --git a/instance/interactions.go b/instance/interactions.go index 1e128a3..0d849ea 100644 --- a/instance/interactions.go +++ b/instance/interactions.go @@ -8,6 +8,16 @@ import ( "github.com/BridgeSenseDev/Dank-Memer-Grinder/utils" ) +func (in *Instance) SendChatMessage(content string, delay bool) error { + if delay { + minDelay := in.Cfg.Cooldowns.CommandInterval.MinDelay + maxDelay := in.Cfg.Cooldowns.CommandInterval.MaxDelay + <-utils.Sleep(time.Duration(rand.Intn(maxDelay-minDelay)+minDelay) * time.Millisecond) + } + + return in.Client.SendChatMessage(content) +} + func (in *Instance) SendCommand(name string, options map[string]string, delay bool) error { if delay { minDelay := in.Cfg.Cooldowns.CommandInterval.MinDelay diff --git a/instance/minigames.go b/instance/minigames.go index eb162f8..98d9eab 100644 --- a/instance/minigames.go +++ b/instance/minigames.go @@ -5,7 +5,6 @@ import ( "github.com/BridgeSenseDev/Dank-Memer-Grinder/gateway" "github.com/BridgeSenseDev/Dank-Memer-Grinder/utils" "regexp" - "strconv" "strings" "github.com/BridgeSenseDev/Dank-Memer-Grinder/discord/types" @@ -85,17 +84,6 @@ func (in *Instance) MinigamesMessageCreate(message gateway.EventMessage) { // Moleman in.solveMinigame(message, "Moleman", "Dodge the Moleman's Worm", []string{worm}) - // Attack boss - if strings.Contains(embed.Description, "Attack the boss by clicking") { - utils.Log(utils.Others, utils.Info, in.SafeGetUsername(), "Solving attack boss minigame") - in.PauseCommands(false) - err := in.ClickButton(message, 0, 0) - if err != nil { - utils.Log(utils.Others, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to click attack boss minigame button: %s", err.Error())) - } - return - } - // Emoji match if strings.Contains(embed.Description, "Look at the emoji closely!") { in.PauseCommands(false) @@ -137,40 +125,6 @@ func (in *Instance) MinigamesMessageCreate(message gateway.EventMessage) { } repeatOrderLastClickedIndex = 0 } - - // F in the chat - if embed.Description == "F" { - err := in.ClickButton(message, 0, 0) - if err != nil { - utils.Log(utils.Others, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to click F in the chat minigame button: %s", err.Error())) - } - utils.Log(utils.Others, utils.Info, in.SafeGetUsername(), "Solved F in the chat minigame") - } - - // HighLow - if strings.Contains(embed.Description, "I just chose a secret number") && message.Interaction.Name != "highlow" { - matches := highlowRegex.FindStringSubmatch(embed.Description) - if len(matches) > 1 { - numStr := matches[1] - num, _ := strconv.Atoi(numStr) - - if num >= 50 { - err := in.ClickButton(message, 0, 0) - if err != nil { - utils.Log(utils.Others, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to click highlow minigame button: %s", err.Error())) - } - } else { - err := in.ClickButton(message, 0, 2) - if err != nil { - utils.Log(utils.Others, utils.Error, in.SafeGetUsername(), fmt.Sprintf("Failed to click highlow minigame button: %s", err.Error())) - } - } - - utils.Log(utils.Others, utils.Info, in.SafeGetUsername(), "Solved highlow minigame") - } else { - utils.Log(utils.Others, utils.Error, in.SafeGetUsername(), "Failed to solve highlow minigame") - } - } } func (in *Instance) MinigamesMessageUpdate(message gateway.EventMessage) {