diff --git a/GolosText-Regular.ttf b/assets/GolosText-Regular.ttf similarity index 100% rename from GolosText-Regular.ttf rename to assets/GolosText-Regular.ttf diff --git a/NotoSerif-Regular.ttf b/assets/NotoSerif-Regular.ttf similarity index 100% rename from NotoSerif-Regular.ttf rename to assets/NotoSerif-Regular.ttf diff --git a/Poppins-Regular.ttf b/assets/Poppins-Regular.ttf similarity index 100% rename from Poppins-Regular.ttf rename to assets/Poppins-Regular.ttf diff --git a/Roboto-Regular.ttf b/assets/Roboto-Regular.ttf similarity index 100% rename from Roboto-Regular.ttf rename to assets/Roboto-Regular.ttf diff --git a/SourceSansPro-Regular.ttf b/assets/SourceSansPro-Regular.ttf similarity index 100% rename from SourceSansPro-Regular.ttf rename to assets/SourceSansPro-Regular.ttf diff --git a/nom.ttf b/assets/nom.ttf similarity index 100% rename from nom.ttf rename to assets/nom.ttf diff --git a/cogs/extra.py b/cogs/extra.py deleted file mode 100644 index 947d570..0000000 --- a/cogs/extra.py +++ /dev/null @@ -1,56 +0,0 @@ -import nextcord -from nextcord.ext import commands, tasks -from nextcord import Interaction, SlashOption -import time, asyncio - -class BotInfoLinkButton(nextcord.ui.View): - def __init__(self): - super().__init__() - self.add_item(nextcord.ui.Button(label="Support Server", url="https://nomindustries.com/SV/support")) - self.add_item(nextcord.ui.Button(label="Invite", url="https://nomindustries.com/SV/invite")) - self.add_item(nextcord.ui.Button(label="Vote", url="https://nomindustries.com/SV/vote")) - self.add_item(nextcord.ui.Button(label="Privacy Policy", url="https://nomindustries.com/SV/privacy")) - -class PrivacyPolicyButton(nextcord.ui.View): - def __init__(self): - super().__init__() - self.add_item(nextcord.ui.Button(label="Privacy Policy", url="https://nomindustries.com/SV/privacy")) - -class Extras(commands.Cog): - - def __init__(self, client): - self.client = client - - @nextcord.slash_command(name="botinfo", description="Shows the bot information") - async def _botinfo( - self, - ctx: Interaction, - ): - await ctx.response.defer() - before = time.monotonic() - msg = await ctx.send("Loading bot information") - ping = (time.monotonic() - before) * 1000 - embed = nextcord.Embed(title="Simple Verification Bot Information", description=f"""Ping: {round(ping)}ms -Server count: {str(len(self.client.guilds))} -Support Server: [Need some support?](https://nomindustries.com/SV/invite) -Invite: [Invite Me](https://nomindustries.com/SV/invite) -Vote: [Vote for me](https://nomindustries.com/SV/vote) -Privacy; [Privacy Policy](https://nomindustries.com/SV/privacy)""", colour=0xadd8e6) - await msg.edit(content = " ", embed=embed, view=BotInfoLinkButton()) - - @nextcord.slash_command(name="guildinfo", description="[ADMIN ONLY]", guild_ids=[1015361041024155770]) - async def _guildinfo(self, ctx:Interaction): - await ctx.response.defer(ephemeral=True) - if ctx.user.id == 326065974950363136: - for i in self.client.guilds: - await ctx.user.send(len(i.members)) - await asyncio.sleep(1) - - @nextcord.slash_command(name="privacy", description=f"Get the link to our privacy policy") - async def privacy_policy(self, ctx:Interaction): - embed = nextcord.Embed(title="Privacy Policy", description="You can find our privacy policy here: \n\nhttps://nomindustries.com/sv/privacy", colour=0xadd8e6) - await ctx.send(embed=embed, view=PrivacyPolicyButton()) - - -def setup(client): - client.add_cog(Extras(client)) \ No newline at end of file diff --git a/cogs/guild_join.py b/cogs/guild_join.py deleted file mode 100644 index 1366596..0000000 --- a/cogs/guild_join.py +++ /dev/null @@ -1,33 +0,0 @@ -import nextcord -from nextcord.ext import commands, tasks -from nextcord import Interaction, SlashOption -from nextcord.abc import GuildChannel -import pymysql, json - -class GuildJoin(commands.Cog): - def __init__(self, client): - self.client = client - - @commands.Cog.listener() - async def on_guild_join(self, guild): - supguild = self.client.get_guild(1111387758028652657) - channel = supguild.get_channel(1111394323720847500) - embed = nextcord.Embed(title=f"Joined Guild", colour=0x03C04A) - embed.add_field(name=f"Guild Name (ID)", value=f"{guild.name} ({guild.id})") - embed.add_field(name=f"Guild Owner", value=f"{guild.owner} (<@{guild.owner.id}>)") - embed.add_field(name=f"Guild Members", value=f"{len(guild.members)}") - await channel.send(embed=embed) - - @commands.Cog.listener() - async def on_guild_remove(self, guild): - supguild = self.client.get_guild(1111387758028652657) - channel = supguild.get_channel(1111394323720847500) - embed = nextcord.Embed(title=f"Left Guild", colour=0x900D09) - embed.add_field(name=f"Guild Name (ID)", value=f"{guild.name} ({guild.id})") - embed.add_field(name=f"Guild Owner", value=f"{guild.owner} (<@{guild.owner.id}>)") - embed.add_field(name=f"Guild Members", value=f"{len(guild.members)}") - await channel.send(embed=embed) - - -def setup(client): - client.add_cog(cog=GuildJoin(client=client)) \ No newline at end of file diff --git a/cogs/help.py b/cogs/help.py index f2e57e0..0cbc8ea 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -1,44 +1 @@ -import nextcord -from nextcord.ext import commands, tasks -from nextcord import Interaction, SlashOption -import json - - -class HelpButtons(nextcord.ui.View): - def __init__(self): - super().__init__() - self.add_item(nextcord.ui.Button(label="Support Server", url="https://discord.gg/aGzvXvTkP8")) - self.add_item(nextcord.ui.Button(label="Invite", url="https://discord.com/api/oauth2/authorize?client_id=981835181243658260&permissions=8&scope=bot%20applications.commands")) - self.add_item(nextcord.ui.Button(label="Vote", url="https://top.gg/bot/828584622156939274/vote")) - - -class Help(commands.Cog): - - def __init__(self, client): - self.client = client - - @nextcord.slash_command(name="help", description="Help command") - async def help(self, - ctx: Interaction): - await ctx.response.defer() - embed = nextcord.Embed(title=(f"Help"), description=(f"""Below is a list of all commands you will need:"""), colour=0xadd8e6) - embed.add_field(name=f"/config enable", value=f"""Explanation: Enable any settings you want to -Requires: Administrator -Usage: ``/config enable``""") - embed.add_field(name=f"/config disable", value=f"""Explanation: Disable any settings you want to -Requires: Administrator -Usage: ``/config disable``""") - embed.add_field(name=f"/verifymessage", value=f"""Explanation: Send a verification message to a channel -Requires: Administrator -Usage: ``/verifymessage <#channel> [Custom (True/False)]``""") - embed.add_field(name=f"/botinfo", value=f"""Explanation: Shows general bot info -Requires: None -Usage: ``/botinfo``""") - embed.add_field(name="\u200B", value=f"[Support Server](https://discord.gg/aGzvXvTkP8) | [Invite Me](https://discord.com/api/oauth2/authorize?client_id=981835181243658260&permissions=8&scope=bot%20applications.commands) | [Vote](https://top.gg/bot/828584622156939274/vote)", inline=False) - - - await ctx.send(embed=embed, view=HelpButtons()) - - -def setup(client): - client.add_cog(Help(client)) \ No newline at end of file +import nextcord \ No newline at end of file diff --git a/cogs/settings.py b/cogs/settings.py deleted file mode 100644 index 5ec062b..0000000 --- a/cogs/settings.py +++ /dev/null @@ -1,184 +0,0 @@ -import nextcord -from nextcord.ext import commands, tasks -from nextcord import Interaction, SlashOption -from nextcord.abc import GuildChannel -import pymysql, json - - -transfer = { - "0" : "None", - "1" : "Choice", - "2" : "Complete" -} - - - -class Settings(commands.Cog): - - def __init__(self, client): - self.client = client - with open('dbconfig.json','r') as jsonfile: - configData = json.load(jsonfile) - self.DBUSER = configData["DBUSER"] - self.DBPASS = configData["DBPASS"] - self.DBNAME = configData["DBNAME"] - self.DBENDPOINT = configData["DBENDPOINT"] - - - - @nextcord.slash_command(name="config", description="Edit your guild settings config") - async def config(self, - ctx: Interaction - ): - pass - - @config.subcommand(name="enable", description="Enable options for your guild settings config") - async def config_enable(self, - ctx: Interaction, - verifyrole : nextcord.Role = SlashOption( - name="verifyrole", - description="The role given when users successfully verify.", - required=False - ), - unverifiedrole : nextcord.Role = SlashOption( - name="unverifiedrole", - description="The role given to users when they join the server.", - required=False - ), - logchannel : GuildChannel = SlashOption( - name="logchannel", - description="Channel to send verification logs to", - required=False, - channel_types=[nextcord.ChannelType.text] - ), - captchatype : str = SlashOption( - name="captchatype", - description="Choose the type of captcha to be sent (Use `/captchatype info` to see the different options)", - required=False, - choices={"None" : "0", "Complete" : "2"} - ), - autokick : int = SlashOption( - name="autokick", - description="Select the minimum age for an account to stay in the server (**In days**)", - required=False - ), - autocaptcha : str = SlashOption( - name="autocaptcha", - description="Enable auto captcha which will automatically start verification on new users who join the server", - required=False, - choices={"Enabled" : "enabled"} - ) - ): - global transfer - await ctx.response.defer() - conn = pymysql.connect(host=self.DBENDPOINT, port=3306, user=self.DBUSER, password=self.DBPASS, db=self.DBNAME) - cur = conn.cursor() - cur.execute(f"SELECT * FROM guild_configs WHERE id='{ctx.guild.id}'") - data = cur.fetchall() - if not data: - cur.execute(f"INSERT INTO guild_configs (id) VALUES ('{ctx.guild.id}')") - conn.commit() - conn = pymysql.connect(host=self.DBENDPOINT, port=3306, user=self.DBUSER, password=self.DBPASS, db=self.DBNAME) - cur = conn.cursor() - if not verifyrole and not unverifiedrole and not logchannel and not captchatype and not autokick and not autocaptcha: - embed=nextcord.Embed(title=f"Error", description=f"It seems you didn't select any options. Make sure you select any you want to change and try again", colour=0xadd8e6) - await ctx.send(embed=embed) - return - embed=nextcord.Embed(title=f"Guild Config Updated", description=f"You have successfully updated your guild config. A list of changes is listed below:", colour=0xadd8e6) - if verifyrole: - cur.execute(f"UPDATE guild_configs SET verifyrole='{verifyrole.id}' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Verify role", value=f"{verifyrole.mention} ({verifyrole.id})") - if unverifiedrole: - cur.execute(f"UPDATE guild_configs SET unverifiedrole='{unverifiedrole.id}' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Unverified role", value=f"{unverifiedrole.mention} ({unverifiedrole.id})") - if logchannel: - cur.execute(f"UPDATE guild_configs SET logchannel='{logchannel.id}' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Log channel", value=f"{logchannel.mention} ({logchannel.id})") - if captchatype: - cur.execute(f"UPDATE guild_configs SET captchatype='{captchatype}' WHERE id='{ctx.guild.id}'") - captchaname = transfer[captchatype] - embed.add_field(name="Captcha type", value=f"{captchaname}") - if autokick: - if not autokick > 0: - embed.add_field(name="Auto kick", description=f"Cannot set auto kick to less than 1 day") - return - cur.execute(f"UPDATE guild_configs SET autokick='{autokick}' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Auto kick", value=f"{autokick} days") - if autocaptcha: - cur.execute(f"UPDATE guild_configs SET autoveri='{autocaptcha}' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Auto captcha", value=f"Auto captcha has been enabled") - conn.commit() - await ctx.send(embed=embed) - - - @config.subcommand(name="disable", description="Disable options for your guild settings config") - async def config_disable(self, - ctx: Interaction, - verifyrole : str = SlashOption( - name="verifyrole", - description="The role given when users successfully verify.", - required=False, - choices={"Disable" : "disable"} - ), - unverifiedrole : str = SlashOption( - name="unverifiedrole", - description="The role given to users when they join the server.", - required=False, - choices={"Disable" : "disable"} - ), - logchannel : str = SlashOption( - name="logchannel", - description="Channel to send verification logs to", - required=False, - choices={"Disable" : "disable"} - ), - autokick : str = SlashOption( - name="autokick", - description="Select the minimum age for an account to stay in the server (**In days**)", - required=False, - choices={"Disable" : "disable"} - ), - autocaptcha : str = SlashOption( - name="autocaptcha", - description="Enable auto captcha which will automatically start verification on new users who join the server", - required=False, - choices={"Disable" : "disable"} - ) - ): - await ctx.response.defer() - conn = pymysql.connect(host=self.DBENDPOINT, port=3306, user=self.DBUSER, password=self.DBPASS, db=self.DBNAME) - cur = conn.cursor() - cur.execute(f"SELECT * FROM guild_configs WHERE id='{ctx.guild.id}'") - data = cur.fetchall() - if not data: - cur.execute(f"INSERT INTO guild_configs (id) VALUES ('{ctx.guild.id}')") - conn.commit() - conn = pymysql.connect(host=self.DBENDPOINT, port=3306, user=self.DBUSER, password=self.DBPASS, db=self.DBNAME) - cur = conn.cursor() - if not verifyrole and not unverifiedrole and not logchannel and not autokick and not autocaptcha: - embed=nextcord.Embed(title=f"Error", description=f"It seems you didn't select any options. Make sure you select any you want to change and try again", colour=0xadd8e6) - await ctx.send(embed=embed) - return - embed=nextcord.Embed(title=f"Guild Config Updated", description=f"You have successfully updated your guild config. A list of changes is listed below:", colour=0xadd8e6) - if verifyrole: - cur.execute(f"UPDATE guild_configs SET verifyrole=NULL WHERE id='{ctx.guild.id}'") - embed.add_field(name="Verify role", value=f"None") - if unverifiedrole: - cur.execute(f"UPDATE guild_configs SET unverifiedrole=NULL WHERE id='{ctx.guild.id}'") - embed.add_field(name="Unverified role", value=f"None") - if logchannel: - cur.execute(f"UPDATE guild_configs SET logchannel=NULL WHERE id='{ctx.guild.id}'") - embed.add_field(name="Log channel", value=f"None") - if autokick: - cur.execute(f"UPDATE guild_configs SET autokick='0' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Auto kick", value=f"Off") - if autocaptcha: - cur.execute(f"UPDATE guild_configs SET autoveri='no' WHERE id='{ctx.guild.id}'") - embed.add_field(name="Auto captcha", value=f"Off") - conn.commit() - await ctx.send(embed=embed) - - - -def setup(client): - client.add_cog(Settings(client)) \ No newline at end of file diff --git a/cogs/verification.py b/cogs/verification.py deleted file mode 100644 index 49a939a..0000000 --- a/cogs/verification.py +++ /dev/null @@ -1,339 +0,0 @@ -import nextcord -from nextcord.ext import commands, tasks -from nextcord import Interaction, SlashOption -from nextcord.abc import GuildChannel -import json, pymysql, asyncio, random, string, os, sys -from captcha.audio import AudioCaptcha -from captcha.image import ImageCaptcha -from views.answer_view import AnswerModal,AnswerButton -from views.embed_manager_views import EmbedCreationForm -import time -import io -import math -import datetime -from difflib import SequenceMatcher - -verifying = [] -letters = ["a ", "b ", "c ", "d ", "e ", "g ", "k ", "m ", "n ", "o ", "p ", "q ", "s ", "u ", "v ", "w ", "x ", "y ", "z "] - -class BotVerifyLinks(nextcord.ui.View): - def __init__(self): - super().__init__() - self.add_item(nextcord.ui.Button(label="Invite me to your server", url="https://nomindustries.com/SV/invite")) - self.add_item(nextcord.ui.Button(label="Privacy Policy", url="https://nomindustries.com/SV/privacy")) - - -class VerifyButton(nextcord.ui.View): - def __init__(self, client): - self.client = client - super().__init__(timeout=None) - self.add_item(nextcord.ui.Button(label="Privacy Policy", url="https://nomindustries.com/SV/privacy")) - with open('dbconfig.json','r') as jsonfile: - configData = json.load(jsonfile) - self.DBUSER = configData["DBUSER"] - self.DBPASS = configData["DBPASS"] - self.DBNAME = configData["DBNAME"] - self.DBENDPOINT = configData["DBENDPOINT"] - - async def generate_captcha_string(self): - result_str = "" - allowed = False - f = open("./filter/filter.txt", "r") - lines = f.readlines() - while not allowed: - rangee = random.randint(4,5) - result_str = ''.join(random.choice(letters) for i in range(rangee)) - allowed = True - for line in lines: - similarity = SequenceMatcher(None, (result_str.lower().replace(" ", "")), (line.strip().lower().replace(" ", ""))) - if similarity.ratio() > 0.5: - allowed=False - - return result_str - - @nextcord.ui.button(label='Verify', style=nextcord.ButtonStyle.green, custom_id='verify_button_view:verify') - async def verify(self, button: nextcord.ui.Button, ctx: nextcord.Interaction): - global verifying - if ctx.user.id in verifying: - await ctx.send("You are already verifying. Please complete that verification to verify again", ephemeral=True) - return - else: - verifying.append(ctx.user.id) - await ctx.response.defer(with_message=True, ephemeral=True) - conn = pymysql.connect(host=self.DBENDPOINT, port=3306, user=self.DBUSER, password=self.DBPASS, db=self.DBNAME) - cur = conn.cursor() - cur.execute(f"SELECT * FROM guild_configs WHERE id='{ctx.guild.id}'") - data = cur.fetchall() - if data: - data = data[0] - if not data[1] == None: - if data[4] == "0": # if captcha type is none - try: - veryroleid = data[1] - veryrole = ctx.guild.get_role(int(veryroleid)) - unverifiedrole = None - if not data[2] == None: - unverifiedroleid = data[2] - unverifiedrole = ctx.guild.get_role(int(unverifiedroleid)) - logchannel = None - if not data[3] == None: - logchannelid = data[3] - logchannel = ctx.guild.get_channel(int(logchannelid)) - if (not veryrole in ctx.user.roles) or (unverifiedrole != None and unverifiedrole in ctx.user.roles): - embed =nextcord.Embed(title="Verification", description=f"{ctx.user.mention} has successfully verified", colour=0xadd8e6) - try: - await ctx.user.add_roles(veryrole) - embed.add_field(name="Roles added", value=f"{veryrole.mention}") - if not unverifiedrole == None and unverifiedrole in ctx.user.roles: - try: - await ctx.user.remove_roles(unverifiedrole) - embed.add_field(name="Roles removed", value=f"{unverifiedrole.mention}") - except: - await ctx.send("Failed to remove unverified role.", ephemeral=True) - embed.add_field(name="Roles removed", value=f"Failed to remove unverified role") - index = verifying.index(ctx.user.id) - del verifying[index] - if not logchannel == None: - try: - await logchannel.send(embed=embed) - except: - pass - return - except Exception as e: - print(e) - await ctx.send("Failed to add verified role", ephemeral=True) - embed.add_field(name="Roles added", value=f"Failed to give verified role") - index = verifying.index(ctx.user.id) - del verifying[index] - if not logchannel == None: - try: - await logchannel.send(embed=embed) - except: - pass - return - - await ctx.send(f"You have successfully verified", ephemeral=True, view=BotVerifyLinks()) - - if not logchannel == None: - try: - await logchannel.send(embed=embed) - except: - pass - - - else: - await ctx.send("You are already verified", ephemeral=True, view=BotVerifyLinks()) - - except Exception as e: - print(e) - await ctx.send("Server config not setup properly, contact the server admins to fix this.", ephemeral=True) - - - - - elif data[4] == "2": - try: - veryroleid = data[1] - veryrole = ctx.guild.get_role(int(veryroleid)) - unverifiedrole = None - if not data[2] == None: - unverifiedroleid = data[2] - unverifiedrole = ctx.guild.get_role(int(unverifiedroleid)) - logchannel = None - if not data[3] == None: - logchannelid = data[3] - logchannel = ctx.guild.get_channel(int(logchannelid)) - if (not veryrole in ctx.user.roles) or (unverifiedrole != None and unverifiedrole in ctx.user.roles): - result_str = await self.generate_captcha_string() - image = ImageCaptcha(width = 280, height = 90, fonts=["nom.ttf", "GolosText-Regular.ttf", "NotoSerif-Regular.ttf", "Poppins-Regular.ttf", "Roboto-Regular.ttf", "SourceSansPro-Regular.ttf"], font_sizes=[60]) - data = image.generate(result_str.lower()) - bytes = io.BytesIO() - image.write(result_str, bytes) - bytes.seek(0) - embed=nextcord.Embed(title=(f"Captcha"), description=(f"""You have 1 minute to answer the captcha correctly. - -The captcha will only be **under case** **letters**. -If you get it wrong just click the verify button again and retry"""), colour=0xadd8e6) - try: - answerview = AnswerButton(actual_answer=result_str) - msg = await ctx.send(embed=embed, file=nextcord.File(bytes, f"{ctx.user.id}-captcha.jpg"), ephemeral=True) - logembed=nextcord.Embed(title=f"Verification Started", description=f"{ctx.user.mention} started verification with the captcha attached. The answer to the captcha is `{str(result_str).replace(' ', '')}`", colour=0xadd8e6) - logembed.set_author(name=f"{ctx.user}", icon_url=ctx.user.avatar.url if ctx.user.avatar else None) - logembed.set_image(url=msg.attachments[0].url) - try: - logmsg = await logchannel.send(embed=logembed) - except Exception as e: - print(e) - pass - await msg.edit(view=answerview) - await answerview.wait() - result_str = result_str.replace(" ", "") - answer = answerview.answer - await msg.delete() - if answer == "Too Long ---------------": - await ctx.send("You ran out of time to answer the captcha, please try again.", ephemeral=True) - index = verifying.index(ctx.user.id) - del verifying[index] - logembed=nextcord.Embed(title=f"Verification Failed", description=f"{ctx.user.mention} failed verification with the captcha attached. The answer to the captcha is `{result_str}` but they didn't answer in time.", colour=0xff0000) - logembed.set_author(name=f"{ctx.user}", icon_url=ctx.user.avatar.url if ctx.user.avatar else None) - try: - await logmsg.reply(embed=logembed) - except: - pass - return - if answer.lower() == result_str: - embed =nextcord.Embed(title="Verification", description=f"{ctx.user.mention} has successfully verified", colour=0x00ff00) - try: - await ctx.user.add_roles(veryrole) - embed.add_field(name="Roles added", value=f"{veryrole.mention}") - if not unverifiedrole == None and unverifiedrole in ctx.user.roles: - try: - await ctx.user.remove_roles(unverifiedrole) - embed.add_field(name="Roles removed", value=f"{unverifiedrole.mention}") - except: - await ctx.send("Failed to remove unverified role.", ephemeral=True) - embed.add_field(name="Roles removed", value=f"Failed to remove unverified role") - index = verifying.index(ctx.user.id) - del verifying[index] - if not logchannel == None: - try: - await logmsg.reply(embed=embed) - except: - pass - return - except Exception as e: - print(e) - await ctx.send("Failed to add verified role", ephemeral=True) - embed.add_field(name="Roles added", value=f"Failed to give verified role") - index = verifying.index(ctx.user.id) - del verifying[index] - if not logchannel == None: - try: - await logmsg.reply(embed=embed) - except: - pass - return - await ctx.send(f"You have successfully verified", ephemeral=True, view=BotVerifyLinks()) - - if not logchannel == None: - try: - await logmsg.reply(embed=embed) - except: - pass - else: - await ctx.send(f"Incorrect answer, please try again. Correct answer was `{result_str}`", ephemeral=True) - logembed=nextcord.Embed(title=f"Verification Failed", description=f"{ctx.user.mention} failed verification with the captcha attached. The answer to the captcha is `{result_str}` but their answer was `{answer}`", colour=0xff0000) - logembed.set_author(name=f"{ctx.user}", icon_url=ctx.user.avatar.url if ctx.user.avatar else None) - try: - await logmsg.reply(embed=logembed) - except: - pass - - except Exception as e: - print(e) - await ctx.send("Error sending captcha", ephemeral=True) - try: - os.remove(f"{ctx.user.id}-captcha.jpg") - except: - pass - else: - await ctx.send("You are already verified", ephemeral=True, view=BotVerifyLinks()) - except Exception as e: - print(e) - await ctx.send("Server config not setup properly, contact the server admins to fix this.", ephemeral=True) - - try: - index = verifying.index(ctx.user.id) - del verifying[index] - - except: - pass - - else: - await ctx.send("Server config not setup properly, contact the server admins to fix this.") - index = verifying.index(ctx.user.id) - del verifying[index] - - - -class VerifyMessage(commands.Cog): - def __init__(self, client): - self.client = client - with open('dbconfig.json','r') as jsonfile: - configData = json.load(jsonfile) - self.DBUSER = configData["DBUSER"] - self.DBPASS = configData["DBPASS"] - self.DBNAME = configData["DBNAME"] - self.DBENDPOINT = configData["DBENDPOINT"] - - @nextcord.slash_command(name="verifymessage", description="Send the verification message to a channel") - async def verifymessage(self, - ctx: Interaction, - channel: GuildChannel = SlashOption( - name="channel", - description="Channel to send verification message to", - required=True, - channel_types=[nextcord.ChannelType.text] - ), - custom: bool = SlashOption( - name="custom", - description="Choose to send a custom embed", - required=False - )): - client = self.client - if ctx.user.guild_permissions.administrator == True: - if custom: - options = EmbedCreationForm() - await ctx.response.send_modal(modal=options) - await options.wait() - embed = nextcord.Embed(title=options.embedtitle, description=options.embeddescription, colour=0xadd8e6) - else: - embed=nextcord.Embed(title=f"Verification", description=f"To verify in the server press the button below and follow the instructions from there.", colour=0xadd8e6) - try: - await channel.send(embed=embed, view=VerifyButton(self.client)) - await ctx.send(f"Message sent to {channel.mention}") - except Exception as e: - print(e) - try: - await ctx.send("Error sending message. Make sure I have permission to send messages and embed links in the selected channel.") - except: - pass - else: - await ctx.send("You require `administrator` permissions to perform this command", ephemeral=True) - - - @commands.Cog.listener() - async def on_member_join(self, member): - global verifying - conn = pymysql.connect(host=self.DBENDPOINT, port=3306, user=self.DBUSER, password=self.DBPASS, db=self.DBNAME) - cur = conn.cursor() - cur.execute(f"SELECT * FROM guild_configs WHERE id='{member.guild.id}'") - data = cur.fetchall() - if data: - data = data[0] - if not data[1] == None: - now = datetime.datetime.now(datetime.timezone.utc) - secs = (now - member.created_at).days - kicked = False - if data[5] == "0": - pass - else: - days = int(data[5]) - if secs < days: - try: - await member.send(f"You were kicked from **{member.guild.name}** due to your account age being below their limit of **{days} days**") - except: - pass - await member.kick(reason=f"Account age below server limit of {days} days") - index = verifying.index(member.id) - del verifying[index] - if not data[2] == None: - role = member.guild.get_role(int(data[2])) - await member.add_roles(role) - - - - -def setup(client): - client.add_cog(VerifyMessage(client)) - diff --git a/utils/constants.py b/utils/constants.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/utils.py b/utils/utils.py new file mode 100644 index 0000000..e69de29 diff --git a/views/answer_view.py b/views/answer_view.py deleted file mode 100644 index 09b0bfa..0000000 --- a/views/answer_view.py +++ /dev/null @@ -1,58 +0,0 @@ -import nextcord, string, io, random, os -from gtts import gTTS -from captcha.audio import AudioCaptcha - - - - - -class AnswerButton(nextcord.ui.View): - def __init__(self, actual_answer): - super().__init__(timeout=60) - self.add_item(nextcord.ui.Button(label="Invite me to your server", url="https://nomindustries.com/SV/invite")) - self.add_item(nextcord.ui.Button(label="Privacy Policy", url="https://nomindustries.com/SV/privacy")) - self.actual_answer = actual_answer - self.answer = "Too Long ---------------" - self.audio_sent = False - - @nextcord.ui.button(label = "Answer", style = nextcord.ButtonStyle.green, disabled=False) - async def answer_ready(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): - answerinput = AnswerModal() - await interaction.response.send_modal(answerinput) - await answerinput.wait() - self.answer = answerinput.answer - self.stop() - - @nextcord.ui.button(label="Audio", style = nextcord.ButtonStyle.blurple, disabled=False) - async def audio_captcha(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): - if not self.audio_sent: - answer = " ".join(letter for letter in self.actual_answer.split()) - tts = gTTS(answer) - tts.save(f"{interaction.user.id}-audio.mp3") - msg = await interaction.send(file=nextcord.File(f"{interaction.user.id}-audio.mp3", f"{interaction.user}-audio.mp3"), ephemeral=True) - os.remove(f"{interaction.user.id}-audio.mp3") - self.audio_sent=True - else: - await interaction.send("You have already requested an audio captcha. Please use that to verify.", ephemeral=True) - - - async def on_timeout(self): - self.answer = "Too Long ---------------" - self.stop() - -class AnswerModal(nextcord.ui.Modal): - def __init__(self): - super().__init__(title="What is your answer?") - self.answer = nextcord.ui.TextInput( - label = "What does the captcha say?", - placeholder = "Example: qdvae", - style=nextcord.TextInputStyle.short, - min_length=1, - max_length=10, - required=True - ) - self.add_item(self.answer) - - async def callback(self, interaction: nextcord.Interaction): - self.answer = self.answer.value - self.stop() \ No newline at end of file diff --git a/views/embed_manager_views.py b/views/embed_manager_views.py deleted file mode 100644 index c81dcf5..0000000 --- a/views/embed_manager_views.py +++ /dev/null @@ -1,33 +0,0 @@ -from asyncio import tasks -import nextcord, pymysql -from nextcord.ext import commands - - -class EmbedCreationForm(nextcord.ui.Modal): - def __init__(self): - super().__init__(title="Embed Create", timeout=None) - self.embedtitle = nextcord.ui.TextInput( - label = "What do you want the title to be?", - placeholder = "Tip: Up to 256 characters!", - style=nextcord.TextInputStyle.short, - min_length=1, - max_length=256, - required=True - ) - self.add_item(self.embedtitle) - - self.embeddescription = nextcord.ui.TextInput( - label = "What do you want the description to be?", - placeholder = "Tip: To mention channels do <#channelid> (eg. <#1028741186380365865>)", - style=nextcord.TextInputStyle.paragraph, - min_length=1, - max_length=4000, - required=True - ) - self.add_item(self.embeddescription) - - - async def callback(self, interaction: nextcord.Interaction): - self.embeddescription = self.embeddescription.value - self.embedtitle = self.embedtitle.value - self.stop() \ No newline at end of file