async def rmuser(self, ctx, member: discord.Member = None): if member is not None: category = discord.utils.get(ctx.guild.categories, name="tickets") if category is None: error_embed = utils.MakeEmbed( title="ERROR", description= "an error has occured. There is no Ticket category.") await ctx.send(embed=error_embed) return if ctx.channel.category_id == category.id: await ctx.channel.set_permissions(member, read_messages=False, send_messages=False) successrm = utils.MakeEmbed(title="Ticket", description="I have removed " + member.name + " from this Ticket.") await ctx.send(embed=successrm) else: notinticket = utils.MakeEmbed( title="ERROR", description= "This command must be made in a Ticket Channel!", doFooter=True, color=discord.Color.dark_red()) await ctx.send(embed=notinticket) return else: membernotexist = utils.MakeEmbed( title="ERROR", description="Please Specify a User!", doFooter=True, color=discord.Color.dark_red()) await ctx.send(embed=membernotexist) return
async def identify(self, ctx, name: discord.Member = None): if name is None: embed = utils.MakeEmbed(title="Identify", description="Please Specify which user to Identify", doFooter=True) await ctx.send(embed=embed) else: if name.id: userid = config.USERS.find_one({'user_id': str(name.id)}) if userid is None: nouser = utils.MakeEmbed(title="ERROR", description="User does not Exist.") await ctx.send(embed=nouser) else: studentid = str(userid['student_id']) with open('eggs.csv', newline='') as csvfile: csvReader = csv.reader(csvfile, delimiter=',') for row in csvReader: student_id12 = ''.join(filter(lambda x: x.isdigit(), row[30])) if str(student_id12) in row[30] and str(student_id12) == str(studentid): firstname = row[1] lastname = row[3] discordname = str(name.name) print("Finding " + discordname + "'s name..") studentname = utils.MakeEmbed(title="Identify", description=discordname + "'s" + " name is: " + firstname + " " + lastname) print("Name found, sending") await ctx.send(embed=studentname) else: nouser = utils.MakeEmbed(title="ERROR", description="User does not Exist.", color=config.ERRORCOLOR, doFooter=True) ctx.send(embed=nouser)
async def status(ctx): current_time = time.time() difference = int(round(current_time - start_time)) uptime = str(datetime.timedelta(seconds=difference)) online = 0 offline = 0 await bot.wait_until_ready() theservers = [543059123730644992] for server in theservers: for member in ctx.guild.members: if str(member.status) == 'online': online += 1 elif str(member.status) == 'idle': online += 1 elif str(member.status) == 'offline': offline += 1 elif str(member.status) == 'dnd': online += 1 elif str(member.status) == 'invisible': offline += 1 allmembers = online + offline embed = utils.MakeEmbed( title="Status", description="**HCS Discord Server Status**:\n\nTotal **Members**:" + str(allmembers) + "\nOnline **Members**: " + str(online) + "\nOffline **Members**: " + str(offline) + "\nBot running for: " + uptime + "\n", doFooter=True) await ctx.send(embed=embed)
async def Tickets(self, ctx): embed = utils.MakeEmbed( title="Help - Tickets", description= " - h!ticket - Open a Ticket for supports\n\n - h!close - Close a ticket.\n\n - h!adduser <username or mention> - Add another user to the Ticket.\n\n - h!rmuser <mention> - Remove Mentioned user from Ticket." ) await ctx.send(embed=embed)
async def Roles(self, ctx): embed = utils.MakeEmbed( title="Help - Roles", description= " - h!roles - See the list of available roles.\n\n - h!role <role name> - Join a role.\n\n - h!rmrole <role name> Leave a role." ) await ctx.send(embed=embed)
async def Identify(self, ctx): embed = utils.MakeEmbed( title="Help - Identify", description= " - h!identify <Username or Mention> - Identifies a User's real name.\n\n - h!identifyall - Identify all users in the Discord Server." ) await ctx.send(embed=embed)
async def ticket(self, ctx, *, name: str = None): adminrole = discord.utils.get(ctx.guild.roles, id=543060916086767617) overwrites = { ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False), ctx.author: discord.PermissionOverwrite(read_messages=True), self.bot.user: discord.PermissionOverwrite(read_messages=True), adminrole: discord.PermissionOverwrite(read_messages=True), } ticketcategory = discord.utils.get(ctx.guild.categories, name="tickets") if not ticketcategory: await ctx.guild.create_category_channel(name="tickets") ticketcategory = discord.utils.get(ctx.guild.categories, name="tickets") ticketname = "ticket-{0}".format(ctx.author.id) ticketchannelmade = discord.utils.get(ctx.guild.channels, name=ticketname) if not ticketchannelmade: embed = utils.MakeEmbed(title="Ticket", description="Making your Ticket...", doFooter=True) await ctx.send(embed=embed) ticketchannel = await ctx.guild.create_text_channel( ticketname, overwrites=overwrites, category=ticketcategory) print(ctx.author.name + "Needs A Ticket..") ticketembed = utils.MakeEmbed(title="Ticket", description="Welcome " + ctx.author.mention + " This is your Ticket! ", doFooter=True) await ticketchannel.send(embed=ticketembed) adminmention = await ticketchannel.send("<@&543060916086767617>") adminmention.delete() usermention = await ticketchannel.send(ctx.author.mention) usermention.delete() else: ticketExists = utils.MakeEmbed( title="ERROR", description="You already have a ticket open!", doFooter=True, color=discord.Color.dark_red()) await ctx.send(embed=ticketExists)
async def help(self, ctx): if ctx.invoked_subcommand is None: embed = utils.MakeEmbed( title="Help", description= "For more details on each category please do h!help <Category> \n\n -Identify \n\n -Roles\n\n -Tickets\n\n -Weather", doFooter=True) await ctx.send(embed=embed)
async def role(self, ctx, _role: str = None): if _role is None: embed = utils.MakeEmbed(title="List of Roles:", description=(', '.join(config.role_list)), doFooter=True) await ctx.send(embed=embed) else: if _role.lower() in config.role_list: get_role = discord.utils.get(ctx.guild.roles, name=_role.lower()) if get_role is not None: await ctx.author.add_roles(get_role) print("Adding " + str(ctx.author) + " To Role: " + str(get_role)) embedconfirm = utils.MakeEmbed(title="Added you to Role:", description=str(get_role), doFooter=True) await ctx.send(embed=embedconfirm) else: await ctx.send("That Role Dosen't Exist") else: await ctx.send("That Role Dosen't Exist")
async def rmrole(self, ctx, _role: str = None): if _role is None: embed = utils.MakeEmbed(title="List of Roles:", description=(', '.join(config.role_list)), doFooter=True) await ctx.send(embed=embed) else: get_role = discord.utils.get(ctx.guild.roles, name=_role.lower()) if get_role is not None and get_role in ctx.author.roles: await ctx.author.remove_roles(get_role) print("Removing " + str(ctx.author) + " From Role: " + str(get_role)) embedconfirm = utils.MakeEmbed(title="Removed you From Role:", description=str(get_role), doFooter=True) await ctx.send(embed=embedconfirm) else: embederror = utils.MakeEmbed( title="ERROR", description="You don't have that Role!", doFooter=True, color=config.ERRORCOLOR) await ctx.send(embed=embederror)
async def close(self, ctx): ticketcategory = discord.utils.get(ctx.guild.categories, name="tickets") roleid = 543060916086767617 if ctx.channel.category_id == ticketcategory.id: if ctx.channel.name == "ticket-{0}".format(ctx.author.id): await ctx.channel.delete() elif roleid in [y.id for y in ctx.author.roles]: await ctx.channel.delete() else: noturticketlol = utils.MakeEmbed( title="ERROR", description="This is not your Ticket!", doFooter=True, color=discord.Color.dark_red()) await ctx.send(embed=noturticketlol) else: notinticketcategory = utils.MakeEmbed( title="ERROR", description="This command can only be done in a ticket!", doFooter=True, color=discord.Color.dark_red()) await ctx.send(embed=notinticketcategory)
async def identifyall(self, ctx): Guestrole = discord.utils.get(ctx.guild.roles, id=int(600884705277247489)) freshmen = discord.utils.get(ctx.guild.roles, id=int(543060124600762406)) LeFreshmen = "" sophomore = discord.utils.get(ctx.guild.roles, id=int(543060215646388224)) Sophomores = "" junior = discord.utils.get(ctx.guild.roles, id=int(543060357191827478)) Juniors = "" senior = discord.utils.get(ctx.guild.roles, id=int(543060511441289216)) seniors = "" alumni = discord.utils.get(ctx.guild.roles, id=int(578278845648732173)) TheAlumni = "" loading = await ctx.send("Loading Freshmen...") for member in freshmen.members: if member in Guestrole.members: LeFreshmen += "\n- " + "**" + str(member.display_name) + "**" + " is a Guest" else: student = config.USERS.find_one({'user_id': str(member.id)}) if student is None: await ctx.send("ERROR: Member File Missing for + " + member.mention + ". Aborting Freshmen count") break else: studentid = str(student['student_id']) with open('eggs.csv', newline='') as csvfile: csvReader = csv.reader(csvfile, delimiter=',') for row in csvReader: thestudent_id = ''.join(filter(lambda x: x.isdigit(), row[30])) if str(thestudent_id) in row[30] and str(thestudent_id) == str(studentid): firstname = row[1] lastname = row[3] LeFreshmen += "\n- " + "**" + str(member.display_name) + "**" + " is " + str( firstname) + " " + str(lastname) await loading.edit(content="Loading Sophomores...") for member in sophomore.members: if member in Guestrole.members: Sophomores += "\n- " + "**" + str(member.display_name) + "**" + " is a Guest" else: student = config.USERS.find_one({'user_id': str(member.id)}) if student is None: await ctx.send("ERROR: Member File Missing for + " + member.mention + ". Aborting Sophomore count") break else: studentid = str(student['student_id']) with open('eggs.csv', newline='') as csvfile: csvReader = csv.reader(csvfile, delimiter=',') for row in csvReader: thestudent_id = ''.join(filter(lambda x: x.isdigit(), row[30])) if str(thestudent_id) in row[30] and str(thestudent_id) == str(studentid): firstname = row[1] lastname = row[3] Sophomores += "\n- " + "**" + str(member.display_name) + "**" + " is " + str( firstname) + " " + str(lastname) await loading.edit(content="Loading Juniors...") for member in junior.members: if member in Guestrole.members: Juniors += "\n- " + "**" + str(member.display_name) + "**" + " is a Guest" else: student = config.USERS.find_one({'user_id': str(member.id)}) if student is None: await ctx.send("ERROR: Member File Missing for + " + member.mention + ". Aborting Junior count") break else: studentid = str(student['student_id']) with open('eggs.csv', newline='') as csvfile: csvReader = csv.reader(csvfile, delimiter=',') for row in csvReader: thestudent_id = ''.join(filter(lambda x: x.isdigit(), row[30])) if str(thestudent_id) in row[30] and str(thestudent_id) == str(studentid): firstname = row[1] lastname = row[3] Juniors += "\n- " + "**" + str(member.display_name) + "**" + " is " + str( firstname) + " " + str(lastname) await loading.edit(content="Loading Seniors...") for member in senior.members: if member in Guestrole.members: seniors += "\n- " + "**" + str(member.display_name) + "**" + " is a Guest" else: student = config.USERS.find_one({'user_id': str(member.id)}) if student is None: await ctx.send("ERROR: Member File Missing for + " + member.mention + ". Aborting Senior count") else: studentid = str(student['student_id']) with open('eggs.csv', newline='') as csvfile: csvReader = csv.reader(csvfile, delimiter=',') for row in csvReader: thestudent_id = ''.join(filter(lambda x: x.isdigit(), row[30])) if str(thestudent_id) in row[30] and str(thestudent_id) == str(studentid): firstname = row[1] lastname = row[3] seniors += "\n- " + "**" + str(member.display_name) + "**" + " is " + str( firstname) + " " + str(lastname) await loading.edit(content="Loading Alumni...") for member in alumni.members: if member in Guestrole.members: TheAlumni += "\n- " + "**" + str(member.display_name) + "**" + " is a Guest" else: student = config.USERS.find_one({'user_id': str(member.id)}) if student is None: await ctx.send("ERROR: Member File Missing for + " + member.mention + ". Aborting Alumni count") else: studentid = str(student['student_id']) with open('eggs.csv', newline='') as csvfile: csvReader = csv.reader(csvfile, delimiter=',') for row in csvReader: thestudent_id = ''.join(filter(lambda x: x.isdigit(), row[30])) if str(thestudent_id) in row[30] and str(thestudent_id) == str(studentid): firstname = row[1] lastname = row[3] TheAlumni += "\n- " + "**" + str(member.display_name) + "**" + " is " + str( firstname) + " " + str(lastname) await loading.delete() AlumniEmbed = utils.MakeEmbed(title="**Alumni**", description=TheAlumni) await ctx.send(embed=AlumniEmbed) SeniorEmbed = utils.MakeEmbed(title="**Seniors**", description=seniors) await ctx.send(embed=SeniorEmbed) JuniorEmbed = utils.MakeEmbed(title="**Juniors**", description=Juniors) await ctx.send(embed=JuniorEmbed) SophEmbed = utils.MakeEmbed(title="**Sophomores**", description=Sophomores) await ctx.send(embed=SophEmbed) FreshEmbed = utils.MakeEmbed(title="**Freshmen**", description=LeFreshmen) await ctx.send(embed=FreshEmbed)
async def weather(self, ctx): url = 'http://api.openweathermap.org/data/2.5/weather?lat=42.63&lon=-83.98&appid=2aed60299013fab6b2eadc5e70cb92fa&units=imperial' urlMetric = 'http://api.openweathermap.org/data/2.5/weather?lat=42.63&lon=-83.98&appid=2aed60299013fab6b2eadc5e70cb92fa&units=metric' res = requests.get(url) resMetric = requests.get(urlMetric) data = res.json() dataMetric = resMetric.json() temp = data['main']['temp'] tempMetric = dataMetric['main']['temp'] maxTemp = data['main']['temp_max'] maxTempMetric = dataMetric['main']['temp_max'] minTemp = data['main']['temp_min'] minTempMetric = dataMetric['main']['temp_min'] wind_speed = data['wind']['speed'] description = data['weather'][0]['main'] icon = data['weather'][0]['icon'] if str(icon) == '01d': icon = ':sunny:' elif str(icon) == '02d': icon = ':partly_sunny:' elif str(icon) == '03d': icon = ':white_sun_cloud:' elif str(icon) == '04d': icon = ':cloud:' elif str(icon) == '09d': icon = ':cloud_rain:' elif str(icon) == '10d': icon = ':white_sun_rain_cloud:' elif str(icon) == '11d': icon = ':thunder_cloud_rain:' elif str(icon) == '13d': icon = ':cloud_snow:' elif str(icon) == '50d': icon = ':fog:' elif str(icon) == '01n': icon = ':last_quarter_moon_with_face: ' elif str(icon) == '02n': icon = ':last_quarter_moon_with_face: :cloud:' elif str(icon) == '10n': icon = ':cloud_rain:' elif str(icon) == '03n': icon = ':white_sun_cloud:' elif str(icon) == '04n': icon = ':cloud:' elif str(icon) == '09n': icon = ':cloud_rain:' elif str(icon) == '11n': icon = ':thunder_cloud_rain:' elif str(icon) == '13n': icon = ':cloud_snow:' elif str(icon) == '50n': icon = ':fog:' if str(description) == "Clear" and icon == ":sunny:": description = "Sunny" embed = utils.MakeEmbed(title="The Weather", description='The weather in Hartland, MI is: \n**Description**: {} {} \n**Temperature**: {}°F / {}°C \n**Max Temperature**: {}°F / {}°C \n**Low Temperature**: {}°F / {}°C \n**Wind Speed**: {}mph'.format( description, icon, temp, tempMetric, maxTemp, maxTempMetric, minTemp, minTempMetric, wind_speed), doFooter=True) await ctx.send(embed=embed)
async def purge(ctx): x = config.USERS.delete_many({}) print(x.deleted_count, "Documents deleted.") Guestrole = discord.utils.get(ctx.guild.roles, id=int(600884705277247489)) middleschoolRole = discord.utils.get(ctx.guild.roles, id=int(546025605221711882)) freshmen = discord.utils.get(ctx.guild.roles, id=int(543060124600762406)) sophomore = discord.utils.get(ctx.guild.roles, id=int(543060215646388224)) junior = discord.utils.get(ctx.guild.roles, id=int(543060357191827478)) senior = discord.utils.get(ctx.guild.roles, id=int(543060511441289216)) alumni = discord.utils.get(ctx.guild.roles, id=int(578278845648732173)) for member in Guestrole.members: print("Kicked " + member.name) await member.kick() for member in middleschoolRole.members: print("Kicked " + member.name) await member.kick() for member in freshmen.members: embed = utils.MakeEmbed( title="New HHS Discord", description= "Hello, You have been kicked from the HCS Discord server, it is now going to become the HHS Discord Server, Please rejoin using this link. - " + config.invite_url) await member.send(embed=embed) print("Kicked " + member.name) await member.kick() for member in sophomore.members: embed = utils.MakeEmbed( title="New HHS Discord", description= "Hello, You have been kicked from the HCS Discord server, it is now going to become the HHS Discord Server, Please rejoin using this link. - " + config.invite_url) await member.send(embed=embed) print("Kicked " + member.name) await member.kick() for member in junior.members: if member.id != 245653078794174465: embed = utils.MakeEmbed( title="New HHS Discord", description= "Hello, You have been kicked from the HCS Discord server, it is now going to become the HHS Discord Server, Please rejoin using this link. - " + config.invite_url) await member.send(embed=embed) print("Kicked " + member.name) await member.kick() for member in senior.members: embed = utils.MakeEmbed( title="New HHS Discord", description= "Hello, You have been kicked from the HCS Discord server, it is now going to become the HHS Discord Server, Please rejoin using this link. - " + config.invite_url) await member.send(embed=embed) print("Kicked " + member.name) await member.kick() for member in alumni.members: embed = utils.MakeEmbed( title="New HHS Discord", description= "Hello, You have been kicked from the HCS Discord server, it is now going to become the HHS Discord Server, Please rejoin using this link. - " + config.invite_url) await member.send(embed=embed) print("Kicked " + member.name) await member.kick()
async def ping(ctx): embed = utils.MakeEmbed(title='🏓 PONG 🏓', description="**{0} ms**".format( round(bot.latency * 1000, 1))) await ctx.send(embed=embed)
async def Weather(self, ctx): embed = utils.MakeEmbed(title="Help - Weather", description="h!weather - Check the Weather.") await ctx.send(embed=embed)