diff --git a/cogs/commands.py b/cogs/commands.py index 16b0cbf..5159e83 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -50,21 +50,11 @@ async def code_command(self, ctx): url='https://github.com/antonstech/antonstechbot') await ctx.channel.send(embed=embed) - @commands.command(name="nudes") - async def nudes_command(self, ctx): - if ctx.channel.is_nsfw(): - embed = discord.Embed(title="Nudes") - embed.set_image( - url="https://www.nydailynews.com/resizer/OYta-jTp2D6Xt_Wj_o6zEUqWttE=/415x562/top/arc-anglerfish-arc2-prod-tronc.s3.amazonaws.com/public/7Y53KJVE7FGLZZPD44LTN4QB5I.jpg") - await ctx.channel.send(embed=embed) - else: - await ctx.channel.send("The Channel is not NSFW") - @commands.command(name="clear") @commands.has_permissions(manage_messages=True) async def clear_command(self, ctx, amount=7): await ctx.channel.purge(limit=amount + 1, check=self.ist_gepinnt) - await ctx.send(f"{amount} Nachrichten wurden gelöscht :)") + await ctx.send(f"{amount} Messages were deleted by {ctx.author} :)", delete_after=7) @commands.command(name="list") async def list_command(self, ctx): diff --git a/cogs/meme.py b/cogs/meme.py index b564526..a202468 100644 --- a/cogs/meme.py +++ b/cogs/meme.py @@ -22,10 +22,9 @@ async def meme(self, ctx): img = x["url"] acc = x["author"] votes = x["ups"] - embed = discord.Embed(title=f"{titel}") + embed = discord.Embed(url=link, title=titel) embed.set_image(url=img) embed.set_footer(text=f"Posted by u/{acc} in r/{reddit} with {votes} Upvotes") - embed.add_field(name="Link to the Post", value=f"[{link}]({link})") await ctx.send(embed=embed) except: await basicerror(ctx) diff --git a/cogs/privatechannel.py b/cogs/privatechannel.py index a86fd61..ca1ab25 100644 --- a/cogs/privatechannel.py +++ b/cogs/privatechannel.py @@ -1,3 +1,4 @@ +import asyncio import configparser import datetime import discord @@ -28,6 +29,7 @@ def __init__(self, client): @commands.command(name="privatechannel", aliases=["channel", "privatchannel", "privatkanal", "kanal"]) @commands.cooldown(1, 3, commands.BucketType.user) async def privatechannel(self, ctx, arg1=None, arg2=None, arg3=None): + global categoryname if constants.channel_enable == "false": await ctx.send(f"{ctx.author.mention} this Function is not enabled by the bot hoster") return @@ -89,7 +91,7 @@ async def privatechannel(self, ctx, arg1=None, arg2=None, arg3=None): pass await ctx.send("Custom User Channels are now **activated**") else: - await ctx.send(f"{ctx.author.mention} You are not an Administrator!") + raise MissingPermissions elif arg1 == "off": if ctx.message.author.guild_permissions.administrator: @@ -99,7 +101,7 @@ async def privatechannel(self, ctx, arg1=None, arg2=None, arg3=None): self.database_connection.commit() await ctx.send("Custom User Channels are now **disabled**") else: - await ctx.send(f"{ctx.author.mention} You are not an Administrator!") + raise PermissionError elif arg1 == "create": code2execute = f"SELECT state FROM servers where id = {ctx.guild.id}" @@ -163,32 +165,71 @@ async def privatechannel(self, ctx, arg1=None, arg2=None, arg3=None): await ctx.send(f"This function is not enabled on this Discord.\n" f"Please contact {ctx.guild.owner.mention} if you want to have it activated") elif arg1 == "category": - try: + if ctx.message.author.guild_permissions.administrator: + try: + self.database_connection.commit() + code2execute = f"INSERT INTO categorynames (serverid, name) VALUES ({ctx.guild.id}, '{arg2}')" + mycursor.execute(code2execute) + self.database_connection.commit() + except: + self.database_connection.commit() + code2execute = f"UPDATE categorynames SET name = '{arg2}' WHERE serverid = {ctx.guild.id}" + mycursor.execute(code2execute) + self.database_connection.commit() + await ctx.send(f'The Category where custom user Channels will now be created will be "{arg2}"') + else: + raise PermissionError + + elif arg1 == "remove": + if ctx.message.author.guild_permissions.administrator: + converter = MemberConverter() + member = await converter.convert(ctx, arg2) + code2execute = "SELECT channelid FROM " + f'"{ctx.message.guild.id}"' + " WHERE memberid = " + f"'{member.id}'" + mycursor.execute(code2execute) + result = mycursor.fetchone() self.database_connection.commit() - code2execute = f"INSERT INTO categorynames (serverid, name) VALUES ({ctx.guild.id}, '{arg2}')" + channelid = result[0] + channel = self.client.get_channel(channelid) + await channel.delete() + code2execute = "DELETE FROM " + f'"{ctx.message.guild.id}"' + " WHERE memberid = " + f"'{member.id}'" mycursor.execute(code2execute) self.database_connection.commit() - except: + await ctx.send(f'"{channel.name}" from {member.mention} was removed!') + else: + raise PermissionError + + elif arg1 == "setup": + if ctx.message.author.guild_permissions.administrator: + code2execute = f"UPDATE servers SET state = true WHERE id = {ctx.guild.id}" self.database_connection.commit() - code2execute = f"UPDATE categorynames SET name = '{arg2}' WHERE serverid = {ctx.guild.id}" mycursor.execute(code2execute) self.database_connection.commit() - await ctx.send(f'The Category where custom user Channels will now be created will be "{arg2}"') + try: + code2execute = f'create table "{ctx.guild.id}"(memberid bigint not null constraint "{ctx.guild.id}_pkey" primary key,channelid bigint not null, creation_time timestamp not null)' + mycursor.execute(code2execute) + self.database_connection.commit() + except errors.lookup("42P07"): + pass + await ctx.send("What is the Name of the Category?") + try: + categoryname = await self.client.wait_for("message", timeout=15) + except asyncio.TimeoutError: + await ctx.send(f"{ctx.author.mention} you needed too long to respond!") + return + try: + self.database_connection.commit() + code2execute = f"INSERT INTO categorynames (serverid, name) VALUES ({ctx.guild.id}, '{categoryname.content}')" + mycursor.execute(code2execute) + self.database_connection.commit() + except: + self.database_connection.commit() + code2execute = f"UPDATE categorynames SET name = '{categoryname.content}' WHERE serverid = {ctx.guild.id}" + mycursor.execute(code2execute) + self.database_connection.commit() + await ctx.send(f'The Category where custom user Channels will be created is "{categoryname.content}"') + else: + raise PermissionError - elif arg1 == "remove": - converter = MemberConverter() - member = await converter.convert(ctx, arg2) - code2execute = "SELECT channelid FROM " + f'"{ctx.message.guild.id}"' + " WHERE memberid = " + f"'{member.id}'" - mycursor.execute(code2execute) - result = mycursor.fetchone() - self.database_connection.commit() - channelid = result[0] - channel = self.client.get_channel(channelid) - await channel.delete() - code2execute = "DELETE FROM " + f'"{ctx.message.guild.id}"' + " WHERE memberid = " + f"'{member.id}'" - mycursor.execute(code2execute) - self.database_connection.commit() - await ctx.send(f'"{channel.name}" from {member.mention} was removed!') else: raise CommandNotFound