async def requirements(self, ctx, args): if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed("You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return if not args: embedVar = tools.embed("Please enter a valid arguement", "You have not entered any arguements.") await ctx.send(embed=embedVar) return False if not tools.check(ctx.guild.id): embedVar = tools.embed("You have not set any alarms!", "Please type ``a!help`` for help on how to create one.") await ctx.send(embed=embedVar) return False args = " ".join(args) for date in sorted(db[str(ctx.guild.id)].items()): if date[0] == "channel": continue print(date[0]) if args == date[0]: del db[str(ctx.guild.id)][date[0]] embedVar = tools.embed("Successfully deleted alarm", "Alarm ``" + date[1]["name"] + "`` has been successfully deleted.") await ctx.send(embed=embedVar) return False embedVar = tools.embed("Could not find alarm", "Alarm ``" + args + "`` does not exist.") await ctx.send(embed=embedVar) return False
async def cooldown(self, guild): tasking.append(guild) await self.client.wait_until_ready() while True: if not tools.check(guild): break for date in sorted(db[guild].items()): if date[0] == "channel": continue date = date[1] tz = timezone(timeZones[date["timezone"]]) day = datetime.now(tz) day = day.strftime("%A") if not day in date["disdays"]: if datetime.now(timezone( timeZones[date["timezone"]])).strftime( "%-I:%M%p") == date["time"] + date["apm"]: embedVar = tools.embed( "Alarm", "<@&" + str(date["role"]) + "> " + date["name"]) channel = self.client.get_channel(db[guild]["channel"]) await channel.send(embed=embedVar) mention = await channel.send("<@&" + str(date["role"]) + ">") await mention.delete() await asyncio.sleep((60 - datetime.utcnow().second) + 3)
async def timezones(self, ctx, *args): string = "" for tz in timeZones: string = string + "``{}``: ".format(tz) + timeZones[tz] + "\n" embedVar = tools.embed("Compatible Timezones", string) await ctx.send(embed=embedVar)
async def on_guild_join(self, guild): for channel in guild.text_channels: if channel.permissions_for(guild.me).send_messages: embedVar = tools.embed( "Thank you for adding me to your server", "Please type ``a!help`` to view the command usage.") await channel.send(embed=embedVar) break
async def requirements(ctx, args): if ctx.author.bot: return False if len(args) > 1: embedVar = tools.embed("Please enter a valid role", "If you need help, please type ``a!help``.") await ctx.send(embed=embedVar) return False
async def settime(self, ctx, *args): req = await requirements(self, ctx, args) if not req: return embedVar = tools.embed("Time successfully set!", "Your time has successfully been set.") embedVar.set_footer(text="Alarm ID: {}".format(req)) await ctx.send(embed=embedVar)
async def enableday(self, ctx, *args): req = await requirements(self, ctx, *args) if not req: return embedVar = tools.embed( "Day successfully resumed!", "This alarm will now send a notification on ``{}``.".format( args[1].lower().title())) await ctx.send(embed=embedVar)
async def setchannel(self, ctx, *args): if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed( "You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return id = ''.join(args) channel = None try: channel = self.client.get_channel(int(id)) except: embedVar = tools.embed("Invalid channel ID", "Please enter a valid channel ID.") await ctx.send(embed=embedVar) return if channel == None: embedVar = tools.embed("Invalid channel ID", "Please enter a valid channel ID.") await ctx.send(embed=embedVar) else: for channel in ctx.message.guild.channels: if channel == self.client.get_channel(int(id)): if tools.check(ctx.guild.id) == False: db[str(ctx.guild.id)] = {} db[str(ctx.guild.id)]["channel"] = int(id) embedVar = tools.embed( "Successfully set channel", "Your channel has been successfully set.") await ctx.send(embed=embedVar) return embedVar = tools.embed( "Invalid channel ID", "If you need help, please type ``a!help``.") await ctx.send(embed=embedVar)
async def alarms(self, ctx): try: db[str(ctx.guild.id)] except: embedVar = tools.embed("You have not set any alarms!", "Please type ``a!help`` to view command usage and how to set an alarm") await ctx.send(embed=embedVar) return string = "" for elem in db[str(ctx.guild.id)]: if elem == "channel": continue string = string + "**{}**".format(db[str(ctx.guild.id)][elem]["name"]) + ":\n ㅤ Time: ``{} {} {}`` ".format(db[str(ctx.guild.id)][elem]["time"], db[str(ctx.guild.id)][elem]["apm"], db[str(ctx.guild.id)][elem]["timezone"]) + "\nㅤ ID: ``{}`` \n".format(elem) if string == "": embedVar = tools.embed("You have not set any alarms!", "Please type ``a!help`` to view command usage and how to set an alarm") await ctx.send(embed=embedVar) return embedVar = tools.embed("Server Alarms", string) await ctx.send(embed=embedVar)
def iplot(figure_or_data, **plot_options): """for use in ipython notebooks""" if 'auto_open' not in plot_options: plot_options['auto_open'] = False res = plot(figure_or_data, **plot_options) urlsplit = res['url'].split('/') username, plot_id = urlsplit[-2][1:], urlsplit[-1] # TODO: HACKY! embed_options = dict() if 'width' in plot_options: embed_options['width'] = plot_options['width'] if 'height' in plot_options: embed_options['height'] = plot_options['height'] return tools.embed(username, plot_id, **embed_options)
async def requirements(self, ctx, *args): try: db[str(ctx.guild.id)] except: embedVar = tools.embed( "You have not set any alarms!", "Please type ``a!help`` to view command usage and how to set an alarm" ) await ctx.send(embed=embedVar) return if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed( "You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return if tools.check(ctx.guild.id) == False: embedVar = tools.embed( "You must set a channel before setting an alarm", "Please type ``a!setchannel [channel id]`` to set a channel for the bot to ping in." ) await ctx.send(embed=embedVar) return False if not args[1].lower().title() in disdays: embedVar = tools.embed("Please enter a valid day.", "Please enter a valid day of the week.") print("Not a valid day.") await ctx.send(embed=embedVar) return False if not args[0] in db[str(ctx.guild.id)]: embedVar = tools.embed("Not a valid Alarm ID.", "Please enter a valid alarm ID.") print("Not a valid Alarm ID.") await ctx.send(embed=embedVar) return False if not args[1].lower().title() in db[str( ctx.guild.id)][args[0]]["disdays"]: embedVar = tools.embed( "This day is not disabled for this alarm", "Please type ``a!help`` to view the command usage if you need help." ) print("Date not in DB.") await ctx.send(embed=embedVar) return False db[str(ctx.guild.id)][args[0]]["disdays"].remove(args[1].lower().title()) return True
async def credits(self, ctx, *args): embedVar = tools.embed("Credits", "Bot made by ``ChillPanda#5842`` and ``Pump3d#3682``. Special thanks to ``mege#0951`` for making the profile picture.") await ctx.send(embed=embedVar)
async def help(self, ctx, *args): embedVar = tools.embed("Alarm Bot Help", "``a!help``: This message. \n ``a!settime [Hours:Minutes AM/PM Timezone Role-ID Message]``: Set an alarm (stackable). \n ``a!timezones``: Displays the compatible timezones. \n ``a!setchannel``: Sets the channel for alarm. \n ``a!setrole``: Role ID \n ``a!alarms``: Shows all the current server alarms and their IDs. \n ``a!remove [Alarm Id]``: Delete a certain alarm that has been set. \n ``a!disableday``: Set a day where a certain alarm will NOT send a message. \n ``a!enableday``: Resume a day that was paused. \n ``a!credits``: Displays the credits.") await ctx.send(embed=embedVar)
async def requirements(self, ctx, args): if not ctx.message.author.guild_permissions.administrator: embedVar = tools.embed( "You must be an admin!", "You must have the administrator role to use this command.") await ctx.send(embed=embedVar) return if ctx.author.id == "771153822994530354" or ctx.author.id == "696790718743838793": print("hi") if ctx.author.bot: return False if len(args) < 5: print("Too little arguements") embedVar = tools.embed( "Please enter a valid amount of arguments", "Please check ``a!help`` to see the bot command usage.") await ctx.send(embed=embedVar) return False if args[0] and not ":" in args[0]: print("Time doesnt have colon") embedVar = tools.embed( "Please enter a valid time", "Please enter a valid time using the ``hour:format`` method.") await ctx.send(embed=embedVar) return False if args[0] and len(args[0].split(":")[1]) != 2: print("Minutes is too short") embedVar = tools.embed( "Please enter a valid time", "Please enter a valid arguement for the number of minutes.") await ctx.send(embed=embedVar) return False arg0int = args[0].replace(":", "") if arg0int.isdigit() and int(arg0int) > 1259 or arg0int.isdigit( ) and int(arg0int) < 100: print("Time too long / short") embedVar = tools.embed( "Please enter a valid time", "Please enter a valid time using standard clock format.") await ctx.send(embed=embedVar) return False if args[2] and not args[2].upper() in timeZones: print("Not a valid timezone") embedVar = tools.embed( "Please enter a compatible timezone", "To view the list of compatible timezones, please type ``a!timezones``." ) await ctx.send(embed=embedVar) return False if args[1] and args[1].upper() != "AM" and args[1].upper() != "PM": print("Not AM or PM") embedVar = tools.embed( "Please enter AM or PM as a valid argument", "Please enter a valid time using standard clock format.") await ctx.send(embed=embedVar) return False try: int(args[3]) except: embedVar = tools.embed( "Please enter a valid role ID", "Please enter a valid role id, and do not use mentions.") await ctx.send(embed=embedVar) return False if not discord.utils.get(ctx.message.guild.roles, id=int(args[3])): print("Invalid role") embedVar = tools.embed( "Please enter a valid role ID", "Please enter a valid role id, and do not use mentions.") await ctx.send(embed=embedVar) if tools.check(ctx.guild.id) == False: embedVar = tools.embed( "You must set a channel before setting an alarm", "Please type ``a!setchannel [channel id]`` to set a channel for the bot to ping in." ) await ctx.send(embed=embedVar) return False name = None for x in range(4, len(args)): if name == None: name = args[x] continue name = name + " " + args[x] for date in sorted(db[str(ctx.guild.id)].items()): if date[0] == "channel": continue #date = date[1] #if date["name"] == name: #embedVar = tools.embed("There is already an alarm with the same name!", "Please use ``a!deletealarm`` to delete the previous alarm before setting a new one.") #await ctx.send(embed=embedVar) #return False db[str(ctx.guild.id)][str(ctx.message.id)] = { "time": args[0], "apm": args[1], "timezone": args[2], "role": int(args[3]), "name": name, "disdays": [] } if not str(ctx.guild.id) in tasking: self.client.loop.create_task(cooldown(self, str(ctx.guild.id))) return str(ctx.message.id)