async def rate(self, ctx, number=None): if number: if not number.isdigit() and (number != "-1"): number = 100 self.randEvent = int(number) await ctx.send(embed=make_embed( title="Rate Changed", description=f"Random events are now 1 in {self.randEvent}")) else: await ctx.send(embed=make_embed( title=f"Random Event Rate is currently 1 in {self.randEvent}"))
async def groupUp(self, ctx, groupName, num=1): mJson = jsGet("groups") if groupName in mJson: if str(ctx.author.id) in mJson[groupName]: await self.rep( ctx, num=num, words= f"{groupName} UNITE! {listToString([i.mention for i in userGrab(self.client,mJson[groupName])],', ',' and ')}" ) else: await ctx.send(embed=make_embed( title="Can't Gather Group", footer="You can't unite a group you're not in")) else: await ctx.send(embed=make_embed(title="Group Not Found", footer="Check spelling idk"))
async def groups(self, ctx, force=False): if force: if ctx.author.id not in jsGet("admo")["admin"]: force = False mJson = jsGet("groups") if not force: l = [i for i in mJson if str(ctx.author.id) in mJson[i]] else: l = [i for i in mJson] await ctx.send(embed=make_embed( title="Your Groups", description=listToString(l, ", ", " and ")))
async def groupDisband(self, ctx, groupName, force=False): if force: if ctx.author.id not in jsGet("admo")["admin"]: force = False mJson = jsGet("groups") if str(ctx.author.id) in mJson[groupName] or force: removed = mJson.pop(groupName, None) with open("groups.json", "w") as j: json.dump(mJson, j, indent=2, sort_keys=True) await ctx.send(embed=make_embed( title=f"\"{groupName}\" disbanded", description= f"Members were {listToString([i.mention for i in userGrab(self.client,removed)],', ',' and ')}" )) else: await ctx.send(embed=make_embed( title="Cannot Disband Group", footer="You can't disband a group you're not in"))
async def redditor(self, ctx, user): info = self.userImageScrape(user) c = 5 while (not info) and c > 5: info = self.userImageScrape(user) c -= 1 if not info: await self.redditError(ctx, user) else: if info[3] == True and ctx.channel.is_nsfw() == False: await ctx.send(embed=make_embed( title="Sorry, I can't send this post to a non-NSFW channel", footer= "Try using the command again or make the channel NSFW")) else: await ctx.send(embed=make_embed( title=info[0], image=info[1], footer=f"Posted on r/{info[2]} by u/{info[4]}"))
async def textpost(self, ctx, sub="copypasta"): c = 5 info = self.text_Post_Scrape(sub) while (not info) and c > 0: info = self.post_Scrape(sub) c -= 1 if not info: await self.redditError(ctx, sub) else: if info[3] == True and ctx.channel.is_nsfw() == False: await ctx.send(embed=make_embed( title="Sorry, I can't send this post to a non-NSFW channel", footer= "Try using the command again or make the channel NSFW")) else: await ctx.send(embed=make_embed( title=info[0], description=info[1], footer=f"Posted on r/{info[2]} by u/{info[4]}"))
async def loopNext(self, ctx): ne = self.stat.next_iteration.replace( tzinfo=datetime.timezone.utc) - datetime.datetime.now( datetime.timezone.utc) #print(ne) await ctx.send(embed=make_embed( title= f"{ne.seconds//3600} Hour(s) {int(round((ne.seconds/60)%60, 0))} Minute(s) Until Next Status Loop" ))
async def wiki(self, ctx, *, topic=None): if not topic: topic = wikipedia.random() page = wikipedia.page(title=topic) await ctx.send(embed=make_embed( title=page.title, description=wikipedia.summary(title=topic, sentences=2), link=page.url, footer= "Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects." ))
async def on_command_error(self, ctx, error): #if self.eStat: eType = type(error) #print(eType) eFoot = "This is likely the fault of the bots creator. DM him to let him know!" eColor = 16711680 if eType is commands.CommandInvokeError: await ctx.send(embed=make_embed( title="Command Invoke Error", description=f"Details are: `{error.original}`", color=eColor, footer=eFoot)) # elif eType is commands.CommandNotFound: #took it out bc it was being annoying as fucc # await ctx.send(embed=make_embed(title="Command Not Found", color=eColor,footer=eFoot)) elif eType is commands.MissingRequiredArgument: await ctx.send( embed=make_embed(title=f"Missing argument: `{error.param}`", color=eColor, footer=eFoot)) elif eType is commands.TooManyArguments: await ctx.send( embed=make_embed(title=f"You used too many arguments", color=eColor, footer=eFoot)) elif eType in [commands.UserNotFound, commands.MemberNotFound]: await ctx.send( embed=make_embed(title=f"`{error.argument}` was not found", color=eColor, footer=eFoot)) elif eType is commands.MissingPermissions: await ctx.send(embed=make_embed( title="Must have following permission(s): " + ", ".join([f"`{perm}`" for perm in error.missing_perms]), color=eColor, footer=eFoot)) elif eType is commands.BotMissingPermissions: await ctx.send(embed=make_embed( title="I must have following permission(s): " + ", ".join([f"`{perm}`" for perm in error.missing_perms]), color=eColor, footer=eFoot)) elif eType is commands.NotOwner: await ctx.send(embed=make_embed( title=f"You aren't bot owner", color=eColor, footer=eFoot)) else: await ctx.send(embed=make_embed( title="Something went wrong", color=eColor, footer=eFoot))
async def groupAdd(self, ctx, groupName: str, *, members): if "@" in groupName: await ctx.send(embed=make_embed( title="Missing Argument `groupName`", color=16711680, footer="Name the group something you'll remember!")) else: members = stringToList( removeChar(members, removes=["<", "!", "@", ">"])) #print(members) mJson = jsGet("groups") if groupName not in mJson: mJson[groupName] = members with open("groups.json", "w") as j: json.dump(mJson, j, indent=2, sort_keys=True) await ctx.send(embed=make_embed( title=f"Group: \"{groupName}\" added", description= f"Members are {listToString([i.mention for i in userGrab(self.client,mJson[groupName])],', ',' and ')}" )) else: await ctx.send( embed=make_embed(title="Group already exists", footer="Try using another name"))
async def admin(self, ctx, user: discord.Member = None): action = None with open("admo.json", "r") as j: mJson = json.load(j) #print(f"before: {mJson}") if user and ctx.author.id == me: if user.id in mJson["admin"]: mJson["admin"].remove(user.id) action = f"{userGrab(self.client, users = [user.id])[0].name} removed successfully!" else: mJson["admin"].append(user.id) #print(f"after {mJson}") action = f"{userGrab(self.client, users = [user.id])[0].name} added successfully!" with open("admo.json", "w") as j: json.dump(mJson, j, indent=2, sort_keys=True) await ctx.send(embed=make_embed( title="Admin List", description= f'{memlistToString(self.client, mJson["admin"], separator=", ")}', footer=action))
async def guilds(self, ctx, idk="0"): gList = [] async for guild in self.client.fetch_guilds(limit=150): if (guild.id == int(idk)) and (ctx.author.id in jsGet("admo")["admin"]): await guild.leave() gList.append(f"I left `{guild.name}` (id {guild.id})") else: gList.append(f"`{guild.name}`: {guild.id}") gList.sort() if idk == "-1": sub = f"Your guild list, {ctx.author}" body = listToString(gList, separator="\n") mailSend(sub, body) msg = await ctx.send("Sent!") await msg.delete(delay=2.5) else: await ctx.send(embed=make_embed(title="Servers I'm In", description=listToString( gList, separator="\n")))
async def bible(self, ctx): b = bible() await ctx.send( embed=make_embed(title=b[0], description=b[1], author="God"))
async def redditError(self, ctx, sub): await ctx.send(embed=make_embed( title="Something went wrong", description= f"Requested subreddit: r/{sub} has too many of the wrong post type for the bot to filter", footer="Maybe try again with the opposite command?"))
async def invite(self, ctx): await ctx.send(embed=make_embed( title="Invite me to your server!", link= "https://discord.com/api/oauth2/authorize?client_id=702143271144783904&permissions=8&scope=bot" ))