def getcoolpeople(bot, server, *, priority="low"): from modules.basics import save cap = [1, 15, 30][["low", "medium", "high"].index(priority)] ret = [] bot.priority_day.setdefault("date", None) if bot.priority_day["date"] != str(datetime.utcnow().date()): bot.priority_day["date"] = str(datetime.utcnow().date()) bot.priority_day["servers"] = {} bot.priority_day["servers"].setdefault(server.id, {}) for u in server.members: if u.id not in bot.priority_day["servers"][server.id]: numbers = [] for x in range(len(bot.priority_week)): x = bot.priority_week[x] if server.id in x["servers"]: numbers.append(x["servers"][server.id].get(u.id, 0)) if not numbers: numbers = [0] bot.priority_day["servers"][server.id][u.id] = round( statistics.median(numbers)) save(bot, "priority_day") if bot.priority_day["servers"][server.id][u.id] >= cap: ret.append(u) return ret
def residueedit(bot, member, n, channel): import modules.basics as basics bot.obamaresidue.setdefault(member.guild.id, {}) bot.obamaresidue[member.guild.id].setdefault(member.id, 0) bot.obamaresiduemax.setdefault(member.guild.id, {}) bot.obamaresiduemax[member.guild.id].setdefault(member.id, 0) bot.obamaresidue[member.guild.id][member.id] += n if n > 0: bot.obamaresiduemax[member.guild.id][member.id] += n bot.obamaresidue[member.guild.id][member.id] = round(bot.obamaresidue[member.guild.id][member.id], 2) bot.obamaresiduemax[member.guild.id][member.id] = round(bot.obamaresiduemax[member.guild.id][member.id], 2) basics.save(bot,"obamaresidue") basics.save(bot,"obamaresiduemax") guild = channel.guild id = member.id asyncio.ensure_future(AchievementBrowser.ach_check(bot, guild.get_member(id), channel, "residue",{ "residue": bot.obamaresidue[guild.id][id], "max": bot.obamaresiduemax[guild.id][id] })) return bot.obamaresidue[member.guild.id][member.id]
async def sue(self, context): """Sue somebody. Modifiers: all|list|stats|records : Display stats from previous cases.""" bot = self.bot m = context.message # Modifiers q = basics.contentq(m.content,split=False) q, all = basics.subcommands(context, q,["all|list|stats|records"]) if all != None: lines = [["User"] + list(Sue.getstats(bot, m.author).keys())] pages = [] something = False n = 0 #for a in range(8): if m.guild.id in bot.suepoints.keys(): for k,i in bot.suepoints[m.guild.id].items(): u = m.guild.get_member(k) if u == None: continue l = [] for k,i in Sue.getstats(bot, u).items(): l.append(str(i)) lines.append([basics.truename(bot, u)] + l) something = True if not something: await talking.reply(context,"There aren't any stats on this server.") else: align = ["l"] l = aesthetic.chart(lines,linelimit=20,align=["l"] + (["r"] * (len(lines[0])-1))) for n,x in enumerate(l): pages.append(f"__**Suing Stats**__ (Page {n+1}/{len(l)})\n{x}") rm = PageMessage(bot, validfor=datetime.timedelta(minutes=5), messagecount=1, userids = [m.author.id], pages=pages, context=context) return # Make sure there's a mention if len(m.mentions) == 0: await talking.reply(context,"You need to specify who you want to sue!") return # Initialize stuff if m.guild.id not in bot.suepoints.keys(): bot.suepoints[m.guild.id] = {} for uid in [m.author.id,m.mentions[0].id]: if uid not in bot.suepoints[m.guild.id].keys(): bot.suepoints[m.guild.id][uid] = {} for a in ["suer","suee"]: for b in ["win","lose"]: bot.suepoints[m.guild.id][uid][a + b] = 0 basics.save(self.bot, "suepoints") reason = basics.mentionlesscontent(basics.contentq(m.content,split=False)) if reason == "": reason = "(No reason.)" suemsg = await talking.say(context,"Â",nowebhook=True) rm = Sue(bot, validfor=datetime.timedelta(minutes=5), messagecount=1, suer=m.author, suee=m.mentions[0], reason=reason, context=context)
async def SAVETODICT_give(self): await talking.say( self.context, f"Hey loser. You've been passed this panel ||{self.url} || by {basics.truename(self.bot,context.message.author)} as part of {q}.", channel=self.passonto) self.bot.cyclecomics[self.q]["turn"] = self.passonto.id basics.save(self.bot, "cyclecomics") self.message = "Okay, done."
async def SAVETODICT_upload(self): self.bot.cyclecomics[q]["panelurls"].append(self.image) self.bot.cyclecomics[q]["panelcreators"].append( self.context.message.author.id) basics.save(bot, "cyclecomics") await talking.reply( context, f"Okay, {self.image} has been added. I'm saving the URL, not the actual image. I'm also not your mom(unless you want me to be <:blob_wink:423672830316511232>), so I'm not adding a failsafe if you delete the message and thus an attached image. It'll just not show up and you'll lose all your friends." )
async def ach_display(bot, user, channel, index): achievements = AchievementBrowser.getachievements() index = achievements[index] embed = discord.Embed(title="**__Achievement Unlocked!__**") s = "" for x in index["reward"]: if x[0] == "clothing": s += "\n{} (equip with `s!ch {}`)".format(x[1], x[1]) server = "global" if index["global"] else channel.guild.id bot.hippoclothing.setdefault(server, {}) bot.hippoclothing[server].setdefault(user.id, set()) bot.hippoclothing[server][user.id].add(x[1]) basics.save(bot, "hippoclothing") if x[0] == "ot": oooooo = ot.otedit(bot, user, x[1], True, channel=channel) s += "\n{} Obama Tokens (total is now {})".format(x[1], oooooo) if x[0] == "en": s += "\nEvernick Character Discount" if s != "": # embed.set_footer(text="Rewards:\n"+s) s = "\n\nRewards:" + s embed.add_field(name="{} **{}**".format(index["icon"], index["name"]), value=index["desc"] + s, inline=False) if index["secret"]: embed.set_footer( text= "Because of the ease of obtaining this achievement, it's more valuable as a surprise than a challenge. Keep its requirements to yourself." ) await user.send(embed=embed) # await asyncio.sleep(random.randint(60*2,60*5)) # ADD A DAILY POST ANNOUNCEMENT # main = bot.epicord.get_channel("112760669178241024") # for x in range(random.randint(200, 1000)): # await bot.wait_for_message(channel=main) # embed = discord.Embed(title="**__Achievement Unlocked!__**") # embed.add_field(name="❔ **???**", value="???", inline=False) # await talking.say(main, content=ccc.repuser(bot, user), embed=embed, tts=bot.tts) else: embed.set_footer(text="Use s!ach to see all achievements.") await channel.send(user.mention, embed=embed) # Achievements for getting achiemenets info = [] for n, i in enumerate(achievements): server = "global" if i["global"] else user.guild.id if n not in bot.ach_tracking[server][user.id].keys(): bot.ach_tracking[server][user.id][n] = [] for x in range(0, len(achievements[n][3])): bot.ach_tracking[server][user.id][n].append(False) info.append(bot.ach_tracking[server][user.id][n]) await AchievementBrowser.ach_check(bot, user, channel, "ach", info)
def trackpriority(bot, m): if m.author.bot: return date = str(datetime.utcnow().date()) if len(bot.priority_week) == 0 or bot.priority_week[-1]["date"] != date: bot.priority_week.append({"date": date, "servers": {}}) bot.priority_week[-1]["servers"].setdefault(m.guild.id, {}) bot.priority_week[-1]["servers"][m.guild.id].setdefault(m.author.id, 0) bot.priority_week[-1]["servers"][m.guild.id][m.author.id] += 1 basics.save(bot, "priority_week")
async def reply(self, context): """Toggles pings on most commands.""" m = context.message u = m.author bot = self.bot if u.id in bot.disablereplyping: bot.disablereplyping.remove(u.id) await talking.reply(context, "You've enabled pings on most commands.") else: bot.disablereplyping.append(u.id) await talking.reply(context, "You've disabled pings on most commands.") basics.save(bot,"disablereplyping") print(bot.disablereplyping)
def __init__(self, bot, **kwargs): OngoingReactionMenu.__init__(self, bot, **kwargs) # Setup defaults = { "differentchannel": self.bot.epicord.get_channel(488516474735034389) if self.context.message.guild.id == self.bot.epicord.id else None } self.userids = [self.context.message.author.id] self.personpicked = None self.bot.sdailylast[self.context.message.guild.id][str( self.context.message.author.id)] = str(datetime.utcnow().date()) basics.save(self.bot, "sdailylast") DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])
async def spawnbronze(bot, m): import modules.basics as basics if ( ( m.server.id not in bot.bronzetimeout.keys() or bot.bronzetimeout[m.server.id]<datetime.utcnow() ) and ( ( m.server==bot.epicord and random.randint(1,3000)<=1 ) or ( m.server.id=="403747701566734336" and random.randint(1,6000)<=1 and m.channel.id!="403754297277284372" ) ) and False ) or ( m.author==bot.rnl and m.content.startswith("s!triggerbronze") ): bot.bronzetimeout[m.server.id]=datetime.utcnow()+timedelta(hours=24) basics.save(bot,"bronzetimeout") bronze = mf.get_emoji(bot,"394586633422372885") total=100 msglst=[] async for msg in bot.logs_from(m.channel, limit=100, reverse=True): if msg.type==discord.MessageType.default: msglst.append(msg) random.shuffle(msglst) if len(msglst)<total: return editmsg=await mf.say(context,"<:obamabronze:393623097598803987> @here An Obama Bronze Rush has started! 100 Obama Bronzes have spawned in the above 100 messages. Snatch them up before everyone else!\n\nObama Bronze waiting to be collected: "+bronzestr(total)) bot.bronzerushes.append([total,editmsg,{}])######## await bot.send_message(bot.testserver.get_channel("382641553803444224"),"ignore pinned message;{}".format(editmsg.id)) try: await bot.pin_message(editmsg) async for pinannouncemsg in bot.logs_from(m.channel, limit=15, reverse=False): if str(pinannouncemsg.type)=="MessageType.pins_add": await bot.delete_message(pinannouncemsg) break except: pass
async def end(self): asyncio.ensure_future(OngoingReactionMenu.end(self)) i = "" g = "" ip = 0 # Innocent Points gp = 0 for x in self.innocentlist: i += f" <@{x}>\n" ip += 1 for x in self.guiltylist: g += f" <@{x}>\n" gp += 1 p = gp - ip # Actual guilty points if p > 0: # Guilty self.bot.suepoints[self.context.guild.id][ self.suer.id]["suerwin"] += p self.bot.suepoints[self.context.guild.id][ self.suee.id]["sueelose"] += p elif p < 0: # Innocent self.bot.suepoints[self.context.guild.id][ self.suer.id]["suerlose"] += abs(p) self.bot.suepoints[self.context.guild.id][ self.suee.id]["sueewin"] += abs(p) basics.save(self.bot, "suepoints") await talking.say( self.context, f"""The results of {self.suer.mention} attempting to sue {self.suee.mention} are in! **Reason:** {self.reason} Innocent: {i} Guilty: {g}""")
def covid(bot, country, section, includedate=False): if bot.covidstats["confirmed"]["last_updated"].split("T")[0] != str( datetime.utcnow().date()): response = requests.get( "https://coronavirus-tracker-api.herokuapp.com/all") bot.covidstats = json.loads(response.text) basics.save(bot, "covidstats") print("Updated covid.") j = bot.covidstats[section] n = 0 found = False if country: for x in j["locations"]: if country.lower() in [ x["country"].lower(), x["country_code"].lower(), x["province"].lower() ]: found = True n += max(x["history"].values()) if includedate: return n if found else None, j["last_updated"].replace( "T", " ").split(".")[0] else: return n if found else None
def otedit(bot, member, n, affectmax, *, channel=None, type=None, extras={}): import modules.basics as basics if member.guild.id not in bot.obamatokens.keys(): bot.obamatokens[member.guild.id] = {} if member.guild.id not in bot.obamatokensmax.keys(): bot.obamatokensmax[member.guild.id] = {} if member.guild.id not in bot.obamatokensgiven.keys(): bot.obamatokensgiven[member.guild.id] = {} if member.id not in bot.obamatokens[member.guild.id].keys(): bot.obamatokens[member.guild.id][member.id] = 0 if member.id not in bot.obamatokensmax[member.guild.id].keys(): bot.obamatokensmax[member.guild.id][member.id] = bot.obamatokens[member.guild.id][member.id] if member.id not in bot.obamatokensgiven[member.guild.id].keys(): bot.obamatokensgiven[member.guild.id][member.id] = 0 bot.obamatokens[member.guild.id][member.id] += n if n > 0 and affectmax == True: bot.obamatokensmax[member.guild.id][member.id] += n if n > 0 and affectmax == False: bot.obamatokensgiven[member.guild.id][member.id] += n if n < 0: bot.obamatokensgiven[member.guild.id][member.id] += n if bot.obamatokensgiven[member.guild.id][member.id] < 0: bot.obamatokensgiven[member.guild.id][member.id] = 0 bot.obamatokens[member.guild.id][member.id] = round(bot.obamatokens[member.guild.id][member.id], 2) bot.obamatokensmax[member.guild.id][member.id] = round(bot.obamatokensmax[member.guild.id][member.id], 2) bot.obamatokensgiven[member.guild.id][member.id] = round(bot.obamatokensgiven[member.guild.id][member.id], 2) basics.save(bot,"obamatokens") basics.save(bot,"obamatokensmax") basics.save(bot,"obamatokensgiven") if channel != None: guild = channel.guild id = member.id asyncio.ensure_future(AchievementBrowser.ach_check(bot, guild.get_member(id), channel, "ot", [bot.obamatokens[guild.id][id], bot.obamatokensmax[guild.id][id], bot.obamatokensgiven[guild.id][id], type, extras])) return bot.obamatokens[member.guild.id][member.id]
async def removeachievement(self, payload): if payload.user_id == self.bot.rnl.id: bot = self.bot context = self.context pos = self.getgridpos() ach = self.getachievements()[pos] u = self.u.id server = "global" if ach["global"] else context.message.guild.id s = "" if u in bot.ach_tracking[server]: if pos in bot.ach_tracking[server][u]: s += str(bot.ach_tracking[server][u][pos]) + "\n" del bot.ach_tracking[server][u][pos] if u in bot.ach_tracking_count[server]: for x in list(bot.ach_tracking_count[server][u].keys()): if x[0] == pos: s += str(bot.ach_tracking_count[server][u][x]) + "\n" del bot.ach_tracking_count[server][u][x] if u in bot.ach_tracking_history[server]: if pos in bot.ach_tracking_history[server][u]: s += str(bot.ach_tracking_history[server][u][pos]) + "\n" del bot.ach_tracking_history[server][u][pos] basics.save(bot, "ach_tracking") basics.save(bot, "ach_tracking_count") basics.save(bot, "ach_tracking_history") self.establishbaseline(bot, u, context.message.guild.id) if ach["secret"]: await talking.say( context, f"<@{u}>, RNL has removed your progress on {ach['icon']} because he doesn't think it was earned properly, most likley because of a bug. Feel free to correct him if he's dumb." ) await talking.say(context, f"<@{u}> {ach['name']}\n{s}", channel=bot.rnl) else: await talking.say( context, f"<@{u}>, RNL has removed your progress on {ach['name']} because he doesn't think it was earned properly, most likley because of a bug. Feel free to correct him if he's dumb.\n\nOld values:\n{s}" ) await self.removeinputreaction(payload) await self.updatemessage(0)
async def ach_check(bot, user, channel, achtype, info): # if user.id == "277449474476081153": # bot.ach_tracking["277449474476081153"] = {} # Wipes same guy constantly if user.bot: return if type(channel) != discord.TextChannel: return bot.ach_tracking.setdefault("global", {}) bot.ach_tracking.setdefault(user.guild.id, {}) bot.ach_tracking["global"].setdefault(user.id, {}) bot.ach_tracking[user.guild.id].setdefault(user.id, {}) bot.ach_tracking_count.setdefault("global", {}) bot.ach_tracking_count.setdefault(user.guild.id, {}) bot.ach_tracking_count["global"].setdefault(user.id, {}) bot.ach_tracking_count[user.guild.id].setdefault(user.id, {}) achievements = AchievementBrowser.getachievements() for n, i in enumerate(achievements): server = "global" if i["global"] else user.guild.id # Add achivement to tracking if missing if n not in bot.ach_tracking[server][user.id].keys(): bot.ach_tracking[server][user.id][n] = [] for x in range(0, len(achievements[n]["check"])): bot.ach_tracking[server][user.id][n].append(False) # Check what's important if False in bot.ach_tracking[server][user.id][n]: try: for x in range(0, len(achievements[n]["check"])): # Make true or add to if requirements met if bot.ach_tracking[server][user.id][n][x] == False: # INTERMISSION: Add to history bot.ach_tracking_history.setdefault(server, {}) bot.ach_tracking_history[server].setdefault( user.id, {}) if len(i["history"]) >= x + 1: if achtype == i["history"][x][0]: bot.ach_tracking_history[server][ user.id].setdefault(n, {}) history = bot.ach_tracking_history[server][ user.id][n] history.setdefault(x, []) m = info if eval(achievements[n]["history"][x][1]): history[x].append( eval(achievements[n]["history"][x] [2])) # INTERMISSION OVER u = user if achtype == achievements[n]["check"][x][0]: # basic True/False, str means it's just for display if len(achievements[n]["check"][x]) == 2 or ( len(achievements[n]["check"][x]) == 3 and type(achievements[n]["check"][x][2]) is str): m = info history = "fuckyou" if n in bot.ach_tracking_history[server][ user.id]: history = bot.ach_tracking_history[ server][user.id][n] bot.ach_tracking[server][ user.id][n][x] = eval( achievements[n]["check"][x][1]) # Numbers else: if (n, x) not in bot.ach_tracking_count[ server][user.id].keys(): bot.ach_tracking_count[server][ user.id][(n, x)] = 0 m = info bot.ach_tracking_count[server][user.id][( n, x)] += eval( achievements[n]["check"][x][1]) if bot.ach_tracking_count[server][user.id][ (n, x)] >= achievements[n]["check"][x][2]: bot.ach_tracking[server][ user.id][n][x] = True # Reset if needed if achtype == achievements[n]["reset"][x][0]: if eval(achievements[n]["reset"][x][1]): if server in bot.ach_tracking_history: if user.id in bot.ach_tracking_history[ server]: if n in bot.ach_tracking_history[ server][user.id]: if x in bot.ach_tracking_history[ server][user.id][n]: del bot.ach_tracking_history[ server][user.id][n][x] if (n, x) in bot.ach_tracking_count[server][ user.id]: bot.ach_tracking_count[server][user.id][( n, x)] = 0 bot.ach_tracking[server][user.id][n][x] = False if False not in bot.ach_tracking[server][user.id][n]: asyncio.ensure_future( AchievementBrowser.ach_display( bot, user, channel, n)) except Exception as e: f"Achievement Error {type(e).__name__}: {e}\n{i['name']}\n{i['check']}\n{info}" basics.save(bot, "ach_tracking") basics.save(bot, "ach_tracking_count") basics.save(bot, "ach_tracking_history")
async def kothnew(self, context): """Makes you king. Or whatever. The king of the hill will get an automatic crown reaction to their messages. You can also become the queen/loli/furry/cheese, based on what alias you use. Or whatever you type after the command. Use [bot] to make the bot take it. After that, you can put an emoji in brackets to get any emoji. You get an increasingly sexy secondary reaction as you hit 15 minutes, two hours, six hours, and 24 hours uninterupted. You can view the top 10 with [top], [high], or [score]. You can use [long] to view the top 500. You can view everyone's best scores with [best], [one], or [records]. See who's currently king and for how long with [time]. When taking the hill, whoever is already on it gets 5 seconds to say something and defend their title. If you try to take it from somebody you didn't want to take it from, if you say . before they defend, it gets canceled. The command has a starting cooldown of 15 seconds. When the hill is defended successfully, and the attacker isn't the king, that cooldown is increased by half a second for the next 10 minutes. Scores earned after koth's death have a skull next to them. You can hide all the death scores with [legacy].""" bot = self.bot m = context.message q = basics.contentq(context.message.content) q, specialemoji = basics.subcommands(context, q, ["EMOJI"]) words = " ".join(q) legacy = "[legacy]" in words if "[bs]" in words and context.message.author.id == self.bot.rnl.id: self.bot.koth = copy.deepcopy(self.bot.kothlast) basics.save(bot,"koth") await talking.reply(context, "Cool.") return if "[time]" in words: secs = (datetime.utcnow() - self.bot.koth[4]).seconds + ( (datetime.utcnow() - self.bot.koth[4]).days * 24 * 60 * 60) mins = 0 hours = 0 while secs >= 60: mins += 1 secs -= 60 while mins >= 60: hours += 1 mins -= 60 await talking.reply(context, "{} has been {} for the last {}, {}, and {}. If the hill was lost now, it would be worth {} pixels.".format( self.bot.koth[1], self.bot.koth[2], ccc.pluralstr("hour", hours), ccc.pluralstr("minute", mins), ccc.pluralstr("second", secs), koth.pixelcalc(self.bot.koth[4], datetime.utcnow())) ) return if "[top]" in words or "[high]" in words or "[score]" in words: embed = discord.Embed(title="King of the Hill Highscores", type="rich") high = self.bot.kothhigh[::-1][:10] numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split( " ") s = "" for x in range(0, len(high)): if legacy and high[x][4]: continue u = self.bot.epicord.get_member(high[x][0]) limit = 23 if len(u.display_name) > limit: name = u.display_name[:limit - 3] + "..." else: name = "<@!" + high[x][0] + ">" if x <= 9: s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n" else: s += "`" + str(x + 1) + "`" + basics.useremoji(self.bot, high[x][0]) + name + "\n" embed.add_field(name="# User", value=s, inline=True) s = "" for x in high: if legacy and x[4]: continue if x[2] == None: emoji = "👑" elif len(x[2]) == 1: emoji = x[2] else: emoji = "<" + x[2] + ">" name = x[1] limit = 15 if len(name) > limit: name = name[:limit - 3] + "..." s += emoji + name + "\n" embed.add_field(name="Title", value=s, inline=True) s = "" for x in high: if legacy and x[4]: continue seconds = x[3] emoji = "<:bl:230481089251115018>" if seconds > (60 * 60) * 24: emoji = "<:tier4:348277627598929922>" elif seconds > (60 * 60) * 6: emoji = "<:tier3:348279546765901826>" elif seconds > (60 * 60) * 2: emoji = "<:tier2:348276583741521921>" elif seconds > 60 * 15: emoji = "<:tier1:348266722526101505>" if x[4]: emoji = "💀" minutes = 0 while seconds >= 60: seconds -= 60 minutes += 1 hours = 0 while minutes >= 60: minutes -= 60 hours += 1 minutes += round(seconds / 60, 2) s += emoji + str(hours) + " hours, " + str(minutes) + " min.\n" embed.add_field(name="Time", value=s, inline=True) s = "You don't have a score on this list." high = self.bot.kothhigh for x in range(0, len(high)): if high[x][0] == context.message.author.id: s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high)) embed.set_footer(text=s) await mf.say(context, embed=embed) return # WOAH MAMA if "[long]" in words: numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split( " ") msg = await talking.say(context, "Â") for n in numbers + [":bn_up:328724374540779522", ":bn_do:328724374498836500"]: asyncio.ensure_future(self.bot.add_reaction(msg, n.replace("<", "").replace(">", ""))) page = 0 while True: embed = discord.Embed(title="Extended King of the Hill Highscores (Page {})".format(page + 1), type="rich") place = 0 names = ["# User", "Title", "Time"] for place in range(0 + (page * 5), 5 + (page * 5)): # print("uh") high = self.bot.kothhigh[::-1][(place * 10):10 + (place * 10)] s = "" for x in range(0, len(high)): if legacy and high[x][4]: continue u = context.message.guild.get_member(high[x][0]) if u == None: u = self.bot.epicord.get_member(high[x][0]) limit = 16 if len(u.display_name) > limit: name = u.display_name[:limit - 3] + "…" else: name = "<@!" + high[x][0] + ">" if x + (place * 10) <= 9: s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n" else: s += "`" + str(x + 1 + (place * 10)) + ")`" + basics.useremoji(self.bot, high[x][0]) + name + "\n" embed.add_field(name=names[0], value=s, inline=True) s = "" for x in high: if legacy and x[4]: continue if x[2] == None: emoji = "👑" elif len(x[2]) <= 10: emoji = x[2] else: if utility.get_emoji(self.bot, x[2]) != None: emoji = "<" + x[2] + ">" else: emoji = str(utility.get_emoji(self.bot, x[2].split(":")[1])) name = x[1] limit = 15 if len(name) > limit: name = name[:limit - 3] + "…" s += emoji + name + "\n" embed.add_field(name=names[1], value=s, inline=True) s = "" for x in high: if legacy and x[4]: continue seconds = x[3] emoji = "<:bl:230481089251115018>" if seconds > (60 * 60) * 24: emoji = "<:tier4:348277627598929922>" elif seconds > (60 * 60) * 6: emoji = "<:tier3:348279546765901826>" elif seconds > (60 * 60) * 2: emoji = "<:tier2:348276583741521921>" elif seconds > 60 * 15: emoji = "<:tier1:348266722526101505>" if x[4]: emoji = "💀" minutes = 0 while seconds >= 60: seconds -= 60 minutes += 1 hours = 0 while minutes >= 60: minutes -= 60 hours += 1 minutes += round(seconds / 60, 2) s += emoji + str(hours) + "h, " + str(round(minutes, 2)) + "m\n" embed.add_field(name=names[2], value=s, inline=True) names = ["Â", "Â", "Â"] s = "You don't have a score on this list." high = self.bot.kothhigh for x in range(0, len(high)): if high[x][0] == context.message.author.id: s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high)) embed.set_footer(text=s) msg = await talking.edit(context, msg, embed=embed) def tempcheck(reaction, user): return user.id != self.bot.me.id rea = await self.bot.wait_for_reaction(self.bot.buttons, message=msg, check=tempcheck, timeout=120) if rea == None: await self.bot.clear_reactions(msg) break else: await self.bot.remove_reaction(msg, rea[0].emoji, rea[1]) if rea[0].emoji.name == "bn_up": page -= 1 elif rea[0].emoji.name == "bn_do": page += 1 else: page = int(rea[0].emoji.name.replace("bn_", "")) - 1 if page == -1: page = 9 elif page == 10: page = 0 return # WOAH MAMA again if "[best]" in words or "[one]" in words or "[records]" in words: embed = discord.Embed(title="Top King of the Hill Scores For Each Player", type="rich") high = self.bot.kothhigh[::-1] numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split( " ") playersshown = [] s = "" s2 = "" s3 = "" for x in range(0, len(high)): if legacy and high[x][4]: continue if high[x][0] not in playersshown: playersshown.append(high[x][0]) u = context.message.server.get_member(high[x][0]) if u == None: u = self.bot.epicord.get_member(high[x][0]) limit = 16 name = "<@!" + high[x][0] + ">" if u != None: if len(u.display_name) > limit: name = u.display_name[:limit - 3] + "…" else: name = "<@!" + high[x][0] + ">" if x <= 9: s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n" else: s += "`" + str(x + 1) + "`" + basics.useremoji(self.bot, high[x][0]) + name + "\n" if high[x][2] == None: emoji = "👑" elif len(high[x][2]) == 1: emoji = high[x][2] else: emoji = str(utility.get_emoji(self.bot, high[x][2].split(":")[1])) name = high[x][1] limit = 15 if len(name) > limit: name = name[:limit - 3] + "…" s2 += emoji + name + "\n" seconds = high[x][3] emoji = "<:bl:230481089251115018>" if seconds > (60 * 60) * 24: emoji = "<:tier4:348277627598929922>" elif seconds > (60 * 60) * 6: emoji = "<:tier3:348279546765901826>" elif seconds > (60 * 60) * 2: emoji = "<:tier2:348276583741521921>" elif seconds > 60 * 15: emoji = "<:tier1:348266722526101505>" if high[x][4]: emoji = "💀" minutes = 0 while seconds >= 60: seconds -= 60 minutes += 1 hours = 0 while minutes >= 60: minutes -= 60 hours += 1 minutes += round(seconds / 60, 2) s3 += emoji + str(hours) + " hours, " + str(minutes) + " min.\n" embed.add_field(name="# User", value=s[:1024], inline=True) embed.add_field(name="Title", value=s2[:1024], inline=True) embed.add_field(name="Time", value=s3[:1024], inline=True) s = "You don't have a score on this list." high = self.bot.kothhigh for x in range(0, len(high)): if high[x][0] == context.message.author.id: s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high)) embed.set_footer(text=s) await talking.say(context, embed=embed) return if context.message.channel.id != "160197704226439168" and context.message.guild.id != self.bot.testserver.id: await talking.reply(context, "This only works in the bot channel.") return if context.message.author.bot: await talking.reply(context, "Non-RSRB bots can't become king, because multiple people would be able to defend the hill.") return seconds = (datetime.utcnow() - self.bot.kothcooldown).seconds if m.guild.id not in self.bot.kothcooldowndict.keys(): self.bot.kothcooldowndict[m.guild.id] = 15 if seconds < self.bot.kothcooldowndict[m.guild.id]: if m.guild.id not in self.bot.kothcooldownnotovertolddict.keys(): self.bot.kothcooldownnotovertolddict[m.guild.id] = [] if m.author.id not in self.bot.kothcooldownnotovertolddict[m.guild.id]: await talking.reply(context, "Please wait, the cooldown's not over yet.") self.bot.kothcooldownnotovertolddict[m.guild.id].append(m.author.id) else: await self.bot.delete_message(m) return self.bot.kothcooldownnotovertolddict[m.guild.id] = [] bot = False if words.startswith("[bot]"): bot = True words = words[5:] specialemoji = None if words.startswith("[") and words.count("]") != 0: words = words.split("]") specialemoji = words[0][1:].replace("<", "").replace(">", "").strip() errorspecialemoji = str(specialemoji) words = "]".join(words[1:]) msg = await self.bot.send_message(self.bot.testserver.get_channel("329187094620667906"), "hi") try: await self.bot.add_reaction(msg, specialemoji) except: specialemoji = str(utility.get_emoji(self.bot, specialemoji)).replace("<", "").replace(">", "") try: await self.bot.add_reaction(msg, specialemoji) except: await talking.reply(context, "`{}` is not a valid emoji!".format(errorspecialemoji)) return if specialemoji != None: if "hippofrumplequest" in specialemoji: await talking.reply(context, "no") return if "obama" in specialemoji: await talking.reply(context, "no") return self.bot.kothcooldown = datetime.utcnow() if seconds < 15: await talking.reply(context, "Please wait, the cooldown's not over yet.") return seconds = (datetime.utcnow() - self.bot.kothcooldown).seconds u = self.bot.epicord.get_member(self.bot.koth[0]) timestampmsg = await talking.say(context, u.mention + ": Quick! Fight off {} by saying something!\n{}: Say . if this was a mistake.".format( ccc.shownames(context.message.author), context.message.author.mention)) statement = "doesn't defend the hill." if u.id != self.bot.me.id: def tempcheck(m): return m.author == u or (m.author == context.message.author and m.content == ".") reply = await self.bot.wait_for_message(timeout=15, author=None, channel=context.message.channel, content=None, check=tempcheck) if reply != None and reply.author == context.message.author: await talking.reply(context, "Heh. Nice going, mate.") return statement = "" if reply == None: statement = "never defended the hill." # await mf.say(context,u.mention+", nice work. The hill is yours... for now.".format(mf.shownames(context.message.author))) # return else: seconds = (reply.timestamp - timestampmsg.timestamp).seconds if seconds <= 5: await talking.say(context, u.mention + ", nice work. You've defended the hill with {} to spare.".format( ccc.pluralstr("second", round(5 - seconds, 2)))) if context.message.author != u: asyncio.ensure_future(mf.kothincreasecooldown(self.bot, m.guild.id)) return else: statement = "attempted to defend the hill, but was late by {}.".format( ccc.pluralstr("second", round(seconds - 5, 2))) self.bot.kothlast = copy.deepcopy(self.bot.koth) self.bot.kothcooldowndict[m.guild.id] = 15 if self.bot.koth == "": self.bot.koth = [context.message.author.id, ccc.shownames(context.message.author), "king"] basics.save(bot,"koth") elif context.message.author.id == "238459957811478529" or context.message.author.id == "208304366719860737": await talking.reply(context, "F**K OFF!!!") elif context.message.guild != self.bot.epicord and context.message.guild != self.bot.testserver: await talking.reply(context, "You can't overthrow the {} in secret.".format(self.bot.koth[2])) else: if context.message.content[2] == "k": type = "king" if context.message.content[2] == "q": type = "queen" if context.message.content[2] == "l": type = "loli" if context.message.content[2] == "f": type = "furry" if context.message.content[2] == "c": type = "cheese" # if context.message.content[2]=="h": # type = "hippo" if len(words) > 0: type = words.strip() if specialemoji != None: if ":markedforpinning:" in specialemoji: await talking.reply(context, "F**K OFF!!!") return # Save highscore stuff seconds = (datetime.utcnow() - self.bot.koth[4]).seconds seconds += (datetime.utcnow() - self.bot.koth[4]).days * 24 * 60 * 60 add = [self.bot.koth[0], self.bot.koth[2], self.bot.koth[3], seconds, True] added = False rank = 0 for x in range(0, len(self.bot.kothhigh)): if add[3] < self.bot.kothhigh[x][3]: added = True rank = x self.bot.kothhigh.insert(x, add) break if added == False: rank = len(self.bot.kothhigh) self.bot.kothhigh.append(add) basics.save(bot,"kothhigh") emoji = "" if seconds > (60 * 60) * 24: emoji = "<:tier4:348277627598929922>" elif seconds > (60 * 60) * 6: emoji = "<:tier3:348279546765901826>" elif seconds > (60 * 60) * 2: emoji = "<:tier2:348276583741521921>" elif seconds > 60 * 15: emoji = "<:tier1:348266722526101505>" minutes = 0 while seconds >= 60: seconds -= 60 minutes += 1 hours = 0 while minutes >= 60: minutes -= 60 hours += 1 minutes += round(seconds / 60, 2) highs = emoji + str(hours) + " hours and " + str(minutes) + " minutes" try: highs = "\n\n<@{}> lasted {}, ranking at #{}. They've earned {} pixels for a total of {}.".format( self.bot.koth[0], highs, len(self.bot.kothhigh) - rank, koth.pixelcalc(self.bot.koth[4], datetime.utcnow()), mf.pixeledit(self.bot, self.bot.koth[0], mf.pixelcalc(self.bot.koth[4], datetime.utcnow()))) except: pass previouskoth = list(self.bot.koth) if bot == False: await talking.reply(context, "<@{}> {} As such, you've become {} of the hill, overthrowing the previous {}!".format( self.bot.koth[0], statement, type, self.bot.koth[2]) + highs) self.bot.koth = [context.message.author.id, ccc.shownames(context.message.author), type, specialemoji, datetime.utcnow()] else: await talking.reply(context, "<@{}> {} As such, the bot has become {} of the hill, overthrowing the previous {}!".format( self.bot.koth[0], statement, type, self.bot.koth[2]) + highs) # await mf.reply(context,"The bot has become {} of the hill, overthrowing <@{}>, the previous {}!".format(type,self.bot.koth[0],self.bot.koth[2])+highs) self.bot.koth = [self.bot.me.id, ccc.shownames(context.message.guild.me), type, specialemoji, datetime.utcnow()] basics.save(bot,"koth")
async def collect(self, payload): bot = self.bot context = self.context m = context.message u = m.guild.get_member(payload.user_id) tokeninfo = f"Spawn Message ID; {context.message.id}" if u.bot: return self.disrespectcount.setdefault(u.id, 0) if payload.emoji.is_unicode_emoji( ) or payload.emoji.id != 394587421687152640: self.disrespectcount[u.id] += 1 return tokeninfo += f"\nDisrespect Count; {self.disrespectcount[u.id]}" self.disableinputs = True recentspeaker = False timestr = '%Y/%m/%d %I:%M:%S %p' uh = datetime.utcnow() - timedelta(seconds=30) if m.created_at <= uh and m.author.id != u.id and not m.author.bot: recentspeaker = True tokeninfo += f"\nRecent Speaker Message ID; {m.id}\nRecent Speaker Message Timestamp; {m.created_at.strftime(timestr)}" else: async for msg in m.channel.history(limit=60, oldest_first=False, before=m): recentspeaker = False if msg.created_at <= uh: break if msg.author.id != u.id and not msg.author.bot: recentspeaker = True tokeninfo += f"\nRecent Speaker Message ID; {m.id}\nRecent Speaker Message Timestamp; {m.created_at.strftime(timestr)}" break tokeninfo += f"\nCollected At; {uh.strftime(timestr)}" self.bot.dripfeedmonth.setdefault(m.guild.id, "None") month = str(datetime.utcnow().strftime("%Y-%m")) try: dripfeed = self.bot.dripfeedmonth[ m.guild.id] != month and not self.bot.ach_tracking[m.guild.id][ u.id][74][0] except: dripfeed = self.bot.dripfeedmonth[m.guild.id] != month if dripfeed: self.bot.dripfeedmonth[m.guild.id] = month basics.save(self.bot, "dripfeedmonth") tokens = ot.otedit(bot, u, 1, True, channel=m.channel, type="gold", extras={ "disrespectcount": self.disrespectcount[u.id], "recentspeaker": recentspeaker, "delayed": self.delayed, "dripfeed": dripfeed }) bot.preresiduecount.setdefault("gold", {}) bot.preresiduecount["gold"].setdefault(u.id, 5) if bot.preresiduecount["gold"][u.id] > 0: bot.preresiduecount["gold"][u.id] -= 1 await talking.say( context, "<:obamatoken:349037437827284992> " + await talking.replystring( context, "You got an Obama Token! You now have a total of {}. {}\n{} will be shown this message {} before it gets replaced with an Obama Residue." .format( tokens, aesthetic.hoveremoji(tokeninfo.replace( ";", "")), basics.truename(bot, u), ccc.pluralstr("more time", bot.preresiduecount["gold"][u.id])), user=u)) basics.save(bot, "preresiduecount") else: await utility.safelyclear( bot, context.message, [[utility.get_emoji(bot, "349037437827284992")]] ) # Prevents end() from removing the residue ObamaResidue( bot, validfor=timedelta(minutes=60), emoji=utility.get_emoji(bot, "653859091331940355"), otheremojis=[basics.useremoji(self.bot, u)] + utility.reactiontext(str(tokens)), info= f"{u.mention} got an Obama Token. They now have a total of {tokens}.\n>>> {tokeninfo.replace(';', ':').replace(' ',' ')}", context=context) await asyncio.sleep(1) # Prevents end() from removing the residue asyncio.ensure_future(self.end())
def thennicktracking(bot, m): bot.thennicks.setdefault(m.channel.id, collections.OrderedDict()) bot.thennicks[m.channel.id][m.id] = m.author.display_name while len(bot.thennicks[m.channel.id]) > 250: bot.thennicks[m.channel.id].popitem(last=False) basics.save(bot, "thennicks")
async def achievements(self, context): """Opens an achievement display menu. Mention someone to see their achievements instead. Modifiers: top|list|high|rank|ranks : Show a scoreboard. """ bot = self.bot m = context.message q = basics.contentq(context.message.content, split=False) q, top, transfer = basics.subcommands( context, q, ["top|list|high|rank|ranks", "transfer"]) if top != None: achievements = AchievementBrowser.getachievements() embed = discord.Embed(title="Achievement Scoreboard", type="rich") cap = 0 for x in achievements: if x["special"] == False: cap += 1 raredict = {} highdict = {} for s in [m.guild.id, "global"]: for k in self.bot.ach_tracking[s].keys(): u = context.message.guild.get_member(k) if u != None: score = 0 icons = "" for n, x in enumerate(achievements): if x["icon"] not in raredict.keys(): raredict[x["icon"]] = 0 if n in self.bot.ach_tracking[s][k].keys( ) and x["special"] == False: if False not in self.bot.ach_tracking[s][k][n]: score += 1 icons += x["icon"] raredict[x["icon"]] += 1 highdict.setdefault(u.id, [u, 0, ""]) highdict[u.id][1] += score highdict[u.id][2] += icons high = list(highdict.values()) rarelist = [] for k in raredict.keys(): rarelist.append([k, raredict[k]]) rarelist = sorted(rarelist, key=lambda x: x[1]) # await mf.say(context,str(rarelist)) high = sorted(high, key=lambda x: x[1])[::-1] high = high # print(high) numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split( " ") lol = [[ "User", aesthetic.hoveremoji("Bar"), "Progress", "%", "Rarest" ]] for n, x in enumerate(high): lol.append([]) u = x[0] limit = 16 if len(basics.truename(bot, u)) > limit: lol[-1].append(basics.truename(bot, u)[:limit - 1] + "…") else: lol[-1].append(basics.truename(bot, u)) prog = x[1] / cap lol[-1].append(ccc.bar(bot, 1, prog, "mini")) lol[-1].append(f"{x[1]}/{cap}") lol[-1].append(f"{math.floor(prog * 100)}%") rares = "" addedrares = 0 for y in rarelist: if y[0] in x[2]: rares += y[0] addedrares += 1 if addedrares == 6: break lol[-1].append(rares) s = "You don't have any achievements." for x in range(0, len(high)): if high[x][0] == context.message.author and high[x][1] != 0: s = "You're ranked #{}.".format(x + 1) SortableChart(bot, validfor=datetime.timedelta(minutes=5), context=context, lol=lol, align=["l", "l", "unwrap", "l", "l", "unwrap"], addnumbers=True) return elif transfer != None and context.message.author == bot.rnl: tracking = pickle.load((open( 'C:\\Users\\Zachary\\Desktop\\kkk\\Non-GML\\ButtBot\\epicord-bot-master\\saveach_tracking.txt', 'rb'))) count = pickle.load((open( 'C:\\Users\\Zachary\\Desktop\\kkk\\Non-GML\\ButtBot\\epicord-bot-master\\saveach_tracking_count.txt', 'rb'))) achievements = AchievementBrowser.getachievements() for u in tracking.keys(): for n, x in enumerate(tracking[u]): for baseserver in [ bot.epicord, bot.get_guild(403747701566734336) ]: server = "global" if achievements[n][ "global"] else baseserver.id if baseserver.get_member(int(u)) == None: continue bot.ach_tracking.setdefault(server, {}) bot.ach_tracking[server].setdefault(int(u), {}) bot.ach_tracking[server][int(u)].setdefault(n, []) edit = bot.ach_tracking[server][int(u)][n] for nn in range(len(achievements[n]["check"])): if len(edit) < nn + 1: edit.append(False) # # print() # print(edit) # print(edit[nn]) # print(tracking[u]) # print(tracking[u][n]) # print(tracking[u][n][nn]) # print() edit[nn] = tracking[u][n][nn] or edit[nn] if u in count: if (n, nn) in count[u]: bot.ach_tracking_count.setdefault( server, {}) bot.ach_tracking_count[server].setdefault( int(u), {}) bot.ach_tracking_count[server][int( u)].setdefault((n, nn), 0) editc = bot.ach_tracking_count[server][int( u)] editc[(n, nn)] = ccc.highest( [count[u][(n, nn)], editc[(n, nn)]]) await talking.say(context, "cool") basics.save(bot, "ach_tracking") basics.save(bot, "ach_tracking_count") return ####################################THE REAL DEAL! AchievementBrowser(bot, validfor=datetime.timedelta(minutes=10), context=context)
async def daily(self, context): """Opt in or out of free tokens for people you like. Once a day, after a random message, you'll be shown three random people and be offered to give a token to one of them. Use [list] to see which people have opted in and if they've gotten their token today. Use [dm] to toggle getting informed that you recieved a token in DMs rather than the same channel.""" if context.message.guild.id not in self.bot.sdailylast.keys(): self.bot.sdailylast[context.message.guild.id] = {} basics.save(self.bot, "sdailylast") bot = self.bot q = basics.contentq(context.message.content, split=False) if "[dm]" in q: bot = self.bot u = context.message.author if u.id in bot.dmdaily: bot.dmdaily.remove(u.id) await talking.reply( context, "You'll now be informed about getting a daily in the same channel." ) else: bot.dmdaily.append(u.id) await talking.reply( context, "You'll now be informed about getting a daily in a DM.") basics.save(bot, "dmdaily") return if "[list]" in q: lol = [["User", "Last", "Today"]] for k, i in self.bot.sdailylast[context.message.guild.id].items(): try: m = utility.get_member_or_user(bot, context.message.guild, int(k)) if m is not None: lol.append([ basics.truename(bot, m), i.replace("DEFAULT", ""), i == str(datetime.utcnow().date()) ]) except ValueError: pass SortableChart(bot, validfor=timedelta(minutes=10), context=context, lol=lol, initialsort=[0, 1], defaultreverse={1}) return id = str(context.message.author.id) if id not in self.bot.sdailylast[context.message.guild.id].keys(): if id + "DISABLED" in self.bot.sdailylast[ context.message.guild.id].keys(): self.bot.sdailylast[context.message.guild.id][id] = \ self.bot.sdailylast[context.message.guild.id][id + "DISABLED"] del self.bot.sdailylast[context.message.guild.id][id + "DISABLED"] else: self.bot.sdailylast[context.message.guild.id][id] = "DEFAULT" basics.save(self.bot, "sdailylast") await talking.reply( context, "You will now be offered once a day after a random message three potential people to give a token to. Use this command again to turn it off.", reaction=True) return else: self.bot.sdailylast[context.message.guild.id][ id + "DISABLED"] = self.bot.sdailylast[context.message.guild.id][id] del self.bot.sdailylast[context.message.guild.id][id] basics.save(self.bot, "sdailylast") await talking.reply( context, "You've opted back out of dailies. Use this command again to pick up where you left off." ) return
async def cyclecomic(self, context): """Cycle comic manager. Cyclecomics being comics where, repeatedly, one person adds two panels, and then shows only the newest panel to another person. Then they add two panels and pass on only the last panel, and so on. Modifiers: new|create|add : Create a new cyclecomic. join|enter : Add yourself to a previously created cyclecomic. upload|panel|append : Add a panel to a cyclecomic on which it's your turn. pass|give : Make it somebody else's turn on a cycleomic on which it's your turn. view|show|release|spew|display : Display a completed cyclecomic. """ async def SAVETODICT_give(self): await talking.say( self.context, f"Hey loser. You've been passed this panel ||{self.url} || by {basics.truename(self.bot,context.message.author)} as part of {q}.", channel=self.passonto) self.bot.cyclecomics[self.q]["turn"] = self.passonto.id basics.save(self.bot, "cyclecomics") self.message = "Okay, done." async def SAVETODICT_upload(self): self.bot.cyclecomics[q]["panelurls"].append(self.image) self.bot.cyclecomics[q]["panelcreators"].append( self.context.message.author.id) basics.save(bot, "cyclecomics") await talking.reply( context, f"Okay, {self.image} has been added. I'm saving the URL, not the actual image. I'm also not your mom(unless you want me to be <:blob_wink:423672830316511232>), so I'm not adding a failsafe if you delete the message and thus an attached image. It'll just not show up and you'll lose all your friends." ) async def SAVETODICT_view(self): for n, x in enumerate(self.bot.cyclecomics[self.q]["panelurls"]): await talking.say( self.context, f"Panel {n+1}, by <@{self.bot.cyclecomics[self.q]['panelcreators'][n]}>.\n{x}" ) await asyncio.sleep(30) bot = self.bot m = context.message q = basics.contentq(m.content, split=False) q, new, join, upload, give, view = basics.subcommands( context, q, [ r"new|create|add", r"join|enter", r"upload|panel|append", r"pass|give", r"view|show|release|spew|display" ]) refnum = " ".join(q.split(" ")[1:]) q = q.split(" ")[0] qcaps = q q = q.lower() current = bot.cyclecomics if new is not None: for k, i in current.items(): if i["owner"] == m.author.id != bot.rnl.id: await talking.reply( context, "You can only create one cyclecomic at a time per server to prevent spam." ) return if not q: await talking.reply( context, 'Add a nickname to this comic, so that it can be identified by something besides an autogenerated number. Like, I dunno. "penis" or "Chris" or something. Six characters max, limited to numbers, letters, and underscores.' ) elif not re.match(r"^\w{1,6}$", q): await talking.reply( context, 'Six characters max, limited to numbers, letters, and underscores.' ) else: if q in current: await talking.reply( context, f"{basics.spitback(qcaps)} is taken already!") else: current[q] = { "owner": m.author.id, "turn": m.author.id, "creationtime": str(datetime.datetime.utcnow().date()), "panelurls": [], "panelcreators": [], "users": [m.author.id], "qcaps": qcaps, "server": m.guild.id } await talking.reply( context, f"Okay, {basics.spitback(qcaps)} is now added. People can join using `s!cc [join]{current[q]['qcaps']}`" ) basics.save(bot, "cyclecomics") elif join is not None: if not q: await talking.reply( context, "You need to specify which cyclecomic you want to join!") elif q not in current: await talking.reply( context, f"{basics.spitback(qcaps)} doesn't seem to exist.") elif m.author.id in current[q]["users"]: await talking.reply(context, "You're already in this cyclecomic!") else: current[q]["users"].append(m.author.id) basics.save(bot, "cyclecomics") await talking.reply( context, "Coolio, you've been added to this cyclecomic.") elif upload is not None: if not q: await talking.reply( context, "You need to specify which cyclecomic you want to add a panel to!" ) elif q not in current: await talking.reply( context, f"{basics.spitback(qcaps)} doesn't seem to exist.") elif m.author.id not in current[q]["users"]: await talking.reply( context, f"You aren't a member of this cyclecomic. You can join with `s!cc [join]{current[q]['qcaps']}`." ) elif current[q]["turn"] != m.author.id: await talking.reply(context, f"It's not your turn on this cyclecomic.") else: image = await utility.referenceimage(context, returnurl=True) if image: ConfirmMessage( bot, validfor=datetime.timedelta(minutes=5), message= f"Are you sure you want to add ||{image} || to {q}?", image=image, q=q, yesscript=SAVETODICT_upload, context=context) elif give is not None: if not q: await talking.reply( context, "You need to specify which cyclecomic you want to pass off on!" ) elif q not in current: await talking.reply( context, f"{basics.spitback(qcaps)} doesn't seem to exist.") elif m.author.id not in current[q]["users"]: await talking.reply( context, f"You aren't a member of this cyclecomic. You can join with `s!cc [join]{current[q]['qcaps']}`." ) elif current[q]["turn"] != m.author.id: await talking.reply(context, f"It's not your turn on this cyclecomic.") else: try: server = bot.get_guild(current[q]['server']) u = utility.get_member_or_user( bot, server, current[q]['users'][int(refnum)]) except: await talking.reply( context, f"I couldn't figure out who {basics.spitback(refnum)} referred to. Use s!cc {current[q]['qcaps']} and give me the reference number of the peron you want to pass to." ) else: if u.id == m.author.id: await talking.reply( context, f"*You're* {basics.truename(bot,u)}, dummy!") else: if current[q]['panelurls']: url = current[q]['panelurls'][-1] else: url = "I lied. I decieved you. Nothing has been added to this cyclecomic yet." ConfirmMessage( bot, validfor=datetime.timedelta(minutes=5), message= f"Are you sure you want to pass ||{url} || to {basics.truename(bot,u)}?", passonto=u, url=url, q=q, yesscript=SAVETODICT_give, context=context) elif view is not None: if not q: await talking.reply( context, "You need to specify which cyclecomic you want to show!") elif q not in current: await talking.reply( context, f"{basics.spitback(qcaps)} doesn't seem to exist.") elif m.author.id != current[q]["owner"]: await talking.reply( context, f"You don't own this cyclecomic, so you can't set it off.") else: ConfirmMessage( bot, validfor=datetime.timedelta(minutes=5), message= f"Are you sure you want to display the entirety of {q}? You can't turn back. It'll be EVERYWHERE.", q=q, yesscript=SAVETODICT_view, context=context) else: if not q: s = "Here's a list of cyclecomics in this server. Specify one to get more info on it.\n`" for x in current.keys(): s += f"\n{x}" s += "`" await talking.reply(context, s) elif q not in current: await talking.reply( context, f"{basics.spitback(qcaps)} isn't a cyclecomic on this server." ) else: lol = [["User", "Turn", "Owner", "Panels", "Ref. #", "Status"]] for n, x in enumerate(current[q]["users"]): u = utility.get_member_or_user(bot, m.guild, x) lol.append([ basics.truename(bot, u), u.id == current[q]["turn"], u.id == current[q]["owner"], current[q]["panelcreators"].count(u.id), n, aesthetic.statusemoji(bot, u) ]) SortableChart(bot, validfor=datetime.timedelta(minutes=5), context=context, lol=lol, initialsort=[1, 0])