async def ban(self, ctx, member, *, reason): memberid = int(useful.getid(member)) confirmationnumber = random.randint(1000, 9999) embed = discord.Embed(title="You are about to ban user: "******"This action is irreversable. To continue please type `" + str(confirmationnumber) + "` or to cancel, please type `cancel`.",colour=self.bot.getcolour()) embed.add_field(name='User ID: ', value=str(ctx.guild.get_member(memberid).id), inline=False) embed.add_field(name='User discord name: ',value=ctx.guild.get_member(memberid).name + "#" + ctx.guild.get_member(memberid).discriminator,inline=False) embed.add_field(name='Reason: ', value=reason, inline=False) baninfo = await ctx.channel.send(embed=embed) def confirmationcheck(msg): return (msg.content == str(confirmationnumber) or msg.content.lower() == "cancel") and ctx.channel.id == msg.channel.id and msg.author.id == ctx.author.id try: msg = await self.bot.wait_for('message', check=confirmationcheck, timeout=60.0) except asyncio.TimeoutError: await ctx.channel.send(":no_entry: | **" + ctx.author.display_name + "** The reset command has closed due to inactivity.") else: if msg.content == str(confirmationnumber): embed = discord.Embed(title=":exclamation: | You have been banned from " + ctx.guild.name,description="You have been banned from " + ctx.guild.name + ". Details of this ban including reason and user are listed below.",colour=self.bot.getcolour()) embed.add_field(name="User (You):", value=ctx.guild.get_member(memberid).mention + " " + ctx.guild.get_member(memberid).name + "#" + ctx.guild.get_member(memberid).discriminator + " `" + str(ctx.guild.get_member(memberid).id) + "`", inline=False) embed.add_field(name="Issued by:", value=ctx.author.mention + " " + ctx.author.name + "#" + ctx.author.discriminator + " `" + str(ctx.author.id) + "`", inline=False) embed.add_field(name="Reason:", value=reason, inline=False) query = "SELECT * FROM guilds WHERE guildID = $1 AND bantext IS NOT NULL" results = await ctx.bot.db.fetchrow(query, ctx.guild.id) if results: embed.add_field(name="Message from server:", value=results["bantext"]) await ctx.channel.send(":white_check_mark: | Banning user...") await ctx.guild.get_member(memberid).send(embed=embed) await ctx.guild.get_member(memberid).ban(reason=reason) elif msg.content.lower() == "cancel": await ctx.channel.send(":white_check_mark: | Canceled!") await baninfo.delete()
async def setquizmaster(self, ctx, member): memberid = useful.getid(member) if discord.utils.get(ctx.guild.roles, name= "Quizmaster") in ctx.guild.get_member(memberid).roles: await ctx.guild.get_member(memberid).remove_roles(discord.utils.get(ctx.guild.roles, name="Quizmaster")) await ctx.channel.send(":white_check_mark: Removed Quizmaster from " + ctx.guild.get_member(memberid).mention + ".") else: await ctx.guild.get_member(memberid).add_roles(discord.utils.get(ctx.guild.roles, name="Quizmaster")) await ctx.channel.send(":white_check_mark: Granted " + ctx.guild.get_member(memberid).mention + " the Quizmaster role.")
async def botglobalunban(self, ctx, member): memberid = int(useful.getid(member)) connection = await self.bot.db.acquire() async with connection.transaction(): query = "UPDATE Users SET banned = false WHERE userID = $1" await self.bot.db.execute(query, memberid) await self.bot.db.release(connection) await ctx.channel.send(":white_check_mark: | Done!")
async def deletemember(self, ctx, member): memberid = int(useful.getid(member)) connection = await self.bot.db.acquire() async with connection.transaction(): query = "DELETE FROM Users WHERE userID = $1" await self.bot.db.execute(query, memberid) await self.bot.db.release(connection) await ctx.channel.send(":white_check_mark: | Done!")
async def verify(self, ctx, user): userid = useful.getid(user) await ctx.author.send('```**Welcome, '+ctx.guild.get_member(userid).mention+ '!**\n• Please make sure to read #info'+ '\n• To set your profile tags, send <@770758387859456060> a DM with the command *`!info`*'+ '\n• Introduce yourself on #bio if you wish' + '\n• Check out our opt-in channels with the command *`w!ranks`* on #bot!'+ '\n:42a:```') await ctx.author.send("<#331517548636143626> <#331517548636143626> <#331517548636143626> <#331517548636143626> <#331517548636143626> <#331517548636143626> ")
async def cute(self, ctx, member): memberID = useful.getid(member) try: toOutput = self.blueTextFunction( (ctx.guild.get_member(memberID).nick + " is cute and valid and i love them"), False) except TypeError: toOutput = self.blueTextFunction( (ctx.guild.get_member(memberID).name + " is cute and valid and i love them"), False) await ctx.channel.send(toOutput + ":heartpulse:") if self.deleteBlueText and ctx.author.id == 163691476788838401: await ctx.message.delete()
async def unmute(self, ctx, *, member): memberID = useful.getid(member) query = "SELECT * FROM guilds WHERE guildID = $1" result = await ctx.bot.db.fetchrow(query, ctx.guild.id) raidrole = discord.utils.get(ctx.guild.roles, id=result["raidroleid"]) if not raidrole: await ctx.channel.send(":no_entry: | The raid role has not been set! Please use the setraidrole command to set a role.") else: if raidrole not in ctx.guild.get_member(memberID).roles: await ctx.channel.send(":no_entry: | This user is not muted. Use the mute command to mute them.") else: await ctx.guild.get_member(memberID).remove_roles(raidrole) await ctx.channel.send(":white_check_mark: | Unmuted user **" + ctx.guild.get_member(memberID).display_name + "**.") if ctx.guild.id == 331517548636143626: await ctx.guild.get_member(memberID).add_roles(discord.utils.get(ctx.guild.roles, name="User"))
async def bee(self, ctx, user): await ctx.channel.send(":white_check_mark: | Done!") userID = useful.getid(user) beeScript = useful.getscript() tosend = "" for counter in range (0, len(beeScript)-1): if counter % 2000 == 0 or counter == (len(beeScript)-1): if counter % 8000 == 0: await asyncio.sleep(2) try: await ctx.guild.get_member(userID).send(tosend) tosend = "" except: break else: tosend += beeScript[counter]
async def override(self, ctx, member, value): successful = 1 try: value = int(value) except: await ctx.channel.send( ":no_entry: | Please enter a whole number to add or subtract from the users score." ) successful = 0 if successful == 1 and value != 0: memberid = useful.getid(member) query = "SELECT * FROM guildusers WHERE guildID = $1 AND userID = $2" result = await ctx.bot.db.fetchrow(query, ctx.guild.id, memberid) currentvalue = result["pubquizscoreweekly"] currenttotal = result["pubquizscoretotal"] connection = await self.bot.db.acquire() async with connection.transaction(): query = "UPDATE guildusers SET pubquizscoreweekly = $1 WHERE guildID = $2 AND userID = $3" await self.bot.db.execute(query, currentvalue + value, ctx.guild.id, memberid) query = "UPDATE guildusers SET pubquizscoretotal = $1 WHERE guildID = $2 AND userID = $3" await self.bot.db.execute(query, currenttotal + value, ctx.guild.id, memberid) await self.bot.db.release(connection) if value > 0: await ctx.channel.send( ":white_check_mark: | User **" + ctx.guild.get_member(memberid).display_name + " (" + ctx.guild.get_member(memberid).name + "#" + ctx.guild.get_member(memberid).discriminator + ")** has had their weekly and total score increased by **" + str(value) + "**. Their new total is **" + str(currenttotal + value) + "** overall and **" + str(currentvalue + value) + "** this week.") elif value < 0: await ctx.channel.send( ":white_check_mark: | User **" + ctx.guild.get_member(memberid).display_name + " (" + ctx.guild.get_member(memberid).name + "#" + ctx.guild.get_member(memberid).discriminator + ")** has had their weekly and total score reduced by **" + str(value * -1) + "**. Their new total is **" + str(currenttotal + value) + "** overall and **" + str(currentvalue + value) + "** this week.") elif value == 0: await ctx.channel.send( ":no_entry: | The score can not be modified by 0.")
async def correct(self, ctx, *, correctMembers): correctMembers = correctMembers.split(" ") query = "SELECT * FROM guilds WHERE guildID = $1" result = await ctx.bot.db.fetchrow(query, ctx.guild.id) embed = discord.Embed(title="The following users were correct:", colour=self.bot.getcolour()) connection = await self.bot.db.acquire() for i in range(0, len(correctMembers)): memberid = (useful.getid(correctMembers[i])) if result["pubquizlastquestionsuper"] == True: toAdd = round(25 / len(correctMembers)) if toAdd == 12: toAdd = 13 elif len(correctMembers ) == 1 and result["pubquizlastquestionsuper"] == False: toAdd = 16 else: toAdd = 13 - i if toAdd < 10: toAdd = 10 query = "SELECT * FROM guildusers WHERE guildID = $1 AND userID = $2" results = await ctx.bot.db.fetchrow(query, ctx.guild.id, memberid) currentvalue = results["pubquizscoreweekly"] currenttotal = results["pubquizscoretotal"] async with connection.transaction(): query = "UPDATE guildusers SET pubquizscoreweekly = $1 WHERE guildID = $2 AND userID = $3" await self.bot.db.execute(query, currentvalue + toAdd, ctx.guild.id, memberid) query = "UPDATE guildusers SET pubquizscoretotal = $1 WHERE guildID = $2 AND userID = $3" await self.bot.db.execute(query, currenttotal + toAdd, ctx.guild.id, memberid) embed.add_field(name=ctx.guild.get_member(memberid).display_name + " (" + ctx.guild.get_member(memberid).name + "#" + ctx.guild.get_member(memberid).discriminator + ")", inline=False, value="gained **" + str(toAdd) + "** points.") await self.bot.db.release(connection) await ctx.guild.get_channel(int(result["pubquizchannel"]) ).send(embed=embed)
async def toggleChannelFunction(self, ctx, enabledisable, channel=None): if channel == None: channelid = ctx.channel.id else: try: channelid = useful.getid(channel) except: await ctx.channel.send( ":no_entry: | Channel not found! Do I have the `Read Messages` permission in the mentioned channel?" ) return if ctx.guild.get_channel(channelid) != None: if enabledisable == "enable": enableddisabled = "enabled" enabledisablebool = True else: enableddisabled = "disabled" enabledisablebool = False query = "SELECT * FROM Channels WHERE channelid = $1" result = await ctx.bot.db.fetchrow(query, channelid) connection = await self.bot.db.acquire() async with connection.transaction(): if result is None: query = "INSERT INTO Channels (channelID) VALUES($1) ON CONFLICT DO NOTHING" await self.bot.db.execute(query, channelid) query = "UPDATE Channels SET enabled = $1 WHERE channelid = $2" await self.bot.db.execute(query, enabledisablebool, channelid) await self.bot.db.release(connection) await ctx.channel.send(":white_check_mark: | Commands " + enableddisabled + " in **" + ctx.guild.get_channel(channelid).name + "**.") else: await ctx.channel.send( ":no_entry: | Channel not found! Do I have the `Read Messages` permission in the mentioned channel?" )
async def botglobalunban(self, ctx, member): memberid = int(useful.getid(member)) await csql.update("Users", "banned", "false", "userID", str(memberid)) await ctx.channel.send(":white_check_mark: | Unbanned user **<@" + str(memberid) + ">** from all bot commands.")