Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
40eb1d9
start of rewrite
lightninq720 Jul 26, 2023
396e276
Complete rewrite started
lightninq720 Aug 28, 2023
675657b
Initial Setup
lightninq720 Aug 28, 2023
5531f80
..
lightninq720 Aug 28, 2023
f64324b
...
lightninq720 Aug 28, 2023
b0ffee9
....
lightninq720 Aug 28, 2023
6b42ce7
Update dbconstants.py
lightninq720 Aug 28, 2023
3354a61
Update .gitignore
lightninq720 Aug 28, 2023
f1166b8
Update dbconstants.py
lightninq720 Aug 28, 2023
188c17a
Update .gitignore
lightninq720 Aug 28, 2023
7fce513
Update dbconstants.py
lightninq720 Aug 28, 2023
53df2e1
.......
lightninq720 Aug 28, 2023
b63b8ce
ojio
lightninq720 Aug 28, 2023
584e209
Update dbconstants.py
lightninq720 Aug 28, 2023
d2838cf
Delete dbconstants.py
lightninq720 Aug 28, 2023
8119a0f
Work on rewrite
lightninq720 Aug 28, 2023
e4bcfec
More stuff
lightninq720 Aug 28, 2023
44d01e1
more work
lightninq720 Aug 28, 2023
ee7e3ee
Completed `/manage-premium add-server` (Untested)
lightninq720 Aug 29, 2023
3221e4e
More work
lightninq720 Aug 29, 2023
ba86bc9
More work
lightninq720 Aug 29, 2023
c8a5684
More work
lightninq720 Aug 30, 2023
8654318
Added `/shardinfo`
heroescreed Sep 3, 2023
8493877
Added `/debug` & `error_handler.py`
lightninq720 Sep 12, 2023
bc24f56
fixed issues with `/dashboard` and started more
lightninq720 Sep 12, 2023
a5d2b78
Finished Premium
lightninq720 Sep 13, 2023
7629d91
Started base for verify button
lightninq720 Sep 24, 2023
a05f018
Added `/verifymessage`
lightninq720 Sep 26, 2023
d199e82
Update utils.py
lightninq720 Sep 26, 2023
335edbf
Started verified button. Need to + prem support
lightninq720 Sep 26, 2023
f8b22f2
Checks on `/verifymessage`
lightninq720 Sep 27, 2023
ddd4861
more work
lightninq720 Sep 27, 2023
41d19f4
More work (Currently broken)
lightninq720 Nov 17, 2023
96ab9c9
refactor: autofix issues in 15 files
deepsource-autofix[bot] Nov 17, 2023
85d2507
Just need to add multiple role support now
lightninq720 Nov 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dbconfig.json
__pycache__/
__pycache__/
/utils/dbconstants.py
utils/dbconstants.py
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions bot/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import nextcord
import os
from nextcord.ext import commands
from utils.utils import *
from utils.constants import TOKEN

class Bot(commands.AutoShardedBot):
def __init__(self):
super().__init__(shard_count=1, command_prefix="nom!")
self.unloaded_cogs = []

def initialize(self):
self.load_extensions()
self.run(TOKEN)

def load_extensions(self):
for cog in os.listdir("./cogs"):
if cog.endswith(".py"):
try:
self.load_extension(name=f"cogs.{cog[:-3]}")
print(f"Loaded {cog[:-3]} cog")

except Exception as e:
print(e)
print(f"Failed to load {cog[:-3]} cog")
self.unloaded_cogs.append(cog.capitalize()[-3])

async def on_ready(self):
print(f"Logged in as {self.user}!")
print(self.shards)
for shard in self.shards:
await self.change_presence(status=nextcord.Status.online, activity=nextcord.Activity(type=nextcord.ActivityType.playing, name=f"Verifying | Shard: {shard+1}/{len(self.shards)}"), shard_id=shard)
35 changes: 35 additions & 0 deletions cogs/dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import nextcord
from nextcord.ext import commands
from nextcord import Interaction
from utils import check_premium, DBENDPOINT, DBNAME, DBPASS, DBUSER, generate_dashboard, create_warning_embed
from views import DashboardButtons
import pymysql

class Dashboard(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@nextcord.slash_command(name="dashboard", description="Configure the bot on the in-discord dashboard")
async def dashboard(self, interaction: Interaction):
await interaction.response.defer(with_message=True, ephemeral=True)
if not interaction.user.guild_permissions.administrator:
await interaction.send(embed=create_warning_embed(title="Insufficient permissions", description="You need the `administrator` permission to use this."))
return

conn = pymysql.connect(host=DBENDPOINT, port=3306, user=DBUSER, password=DBPASS, db=DBNAME)
cur = conn.cursor()
cur.execute(f"SELECT * FROM guild_configs WHERE id='{interaction.guild.id}'")
data = cur.fetchall()
if not data:
cur.execute(f"INSERT INTO guild_configs (id) VALUES ('{interaction.guild.id}')")
conn.commit()
msg = await interaction.send("Generating Dashboard...", ephemeral=True)
embed = generate_dashboard(self, data=data)
view = DashboardButtons(msg, premium=check_premium(self, guild = True, user = False, type_id=interaction.guild.id))
await msg.edit(content="", embed=embed, view=view)




def setup(client: commands.Bot):
client.add_cog(Dashboard(client))
24 changes: 24 additions & 0 deletions cogs/error_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import nextcord
from cooldowns import CallableOnCooldown
from nextcord.ext import commands
from bot.bot import Bot
from nextcord.errors import Forbidden
from utils import *
import time

class Error_handler(commands.Cog):
def init(self, client: Bot):
self.client = client

@commands.Cog.listener()
async def on_application_command_error(self, interaction:nextcord.Interaction, error):
error = getattr(error, "original", error)
if isinstance(error, CallableOnCooldown):
await interaction.send(f"That command is on cooldown. You can use it again <t:{int(error.retry_after) + round(int(time.time()))}:R>")
elif isinstance(error, Forbidden):
await interaction.send("I don't have permission to do that")
else:
raise error

def setup(client: Bot):
client.add_cog(Error_handler(client))
56 changes: 0 additions & 56 deletions cogs/extra.py

This file was deleted.

33 changes: 0 additions & 33 deletions cogs/guild_join.py

This file was deleted.

45 changes: 15 additions & 30 deletions cogs/help.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
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"))

from nextcord.ext import commands
from nextcord import Interaction
from utils.constants import COLOUR_MAIN, VOTELINK, INVITELINK, DISCORDLINK, PRIVACYLINK
from views import BotInfoLinkButton

class Help(commands.Cog):

def __init__(self, client):
def __init__(self, client: commands.Bot):
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
async def help(self, interaction: Interaction):
await interaction.response.defer()
embed = nextcord.Embed(title=("Help"), description=("""Below is a list of all commands you will need:"""), colour=COLOUR_MAIN)
embed.add_field(name=f"/dashboard", value="""Explanation: Manage the bot's settings
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``""")
Usage: ``/dashboard``""")
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())
embed.add_field(name="\u200B", value=f"[Support Server]({DISCORDLINK}) | [Invite Me]({INVITELINK}) | [Vote]({VOTELINK}) | [Privacy Policy]({PRIVACYLINK})", inline=False)


def setup(client):
await interaction.send(embed=embed, view=BotInfoLinkButton())

def setup(client: commands.Bot):
client.add_cog(Help(client))
83 changes: 83 additions & 0 deletions cogs/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import nextcord
from nextcord.ext import commands
import time
from nextcord import Interaction
from views import BotInfoLinkButton, PrivacyPolicyButton
import cooldowns
from utils.constants import COLOUR_MAIN, VOTELINK, INVITELINK, DISCORDLINK, PRIVACYLINK

class Misc(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@nextcord.slash_command(name="botinfo", description="Information about the bot")
async def botinfo(self, interaction: Interaction):
await interaction.response.defer()
before = time.monotonic()
msg = await interaction.send("Loading bot information")
ping = (time.monotonic() - before) * 1000
users = 0
for guild in self.client.guilds:
users+=guild.member_count
embed = nextcord.Embed(title="Bot Infomation", description=f"""Ping: {round(ping)}ms
Server count: {str(len(self.client.guilds))}
User count: {users:,}
Support Server: [Need some support?]({DISCORDLINK})
Invite: [Invite Me]({INVITELINK})
Vote: [Vote for me]({VOTELINK})
Privacy: [Privacy Policy]({PRIVACYLINK})""", colour=COLOUR_MAIN)
await msg.edit(content = " ", embed=embed, view=BotInfoLinkButton())

@nextcord.slash_command(name="privacy", description="Get the link to our privacy policy")
async def privacy(self, interaction:Interaction):
await interaction.send(content="", view=PrivacyPolicyButton())


@nextcord.slash_command(name="shardinfo", description="Get information on all shards")
@cooldowns.cooldown(1, 30, bucket=cooldowns.SlashBucket.author)
async def shardinfo(self, interaction:Interaction):
await interaction.response.defer()
description = ""
for shard in self.client.shards:
specshard = self.client.get_shard(shard)
shard_servers = len([guild for guild in self.client.guilds if guild.shard_id == shard])
description+=f"\n**Shard {shard+1}** has `{round(specshard.latency*100)}ms` latency with `{shard_servers} servers`"

if not interaction.guild:
await interaction.send(embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
else:
guild_shard = interaction.guild.shard_id
guildspecshard = self.client.get_shard(guild_shard)
guild_shard_servers = len([guild for guild in self.client.guilds if guild.shard_id == guild_shard])
await interaction.send(f"This server's shard is shard **{guild_shard+1}** with `{round(guildspecshard.latency*100)}ms` and `{guild_shard_servers} servers`", embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))



@nextcord.slash_command(name="shardinfo", description="Get information on all shards")
@cooldowns.cooldown(1, 30, bucket=cooldowns.SlashBucket.author)
async def shardinfo(self, interaction:Interaction):
await interaction.response.defer()
description = ""
for shard in self.client.shards:
specshard = self.client.get_shard(shard)
shard_servers = len([guild for guild in self.client.guilds if guild.shard_id == shard])
description+=f"\n**Shard {shard+1}** has `{round(specshard.latency*100)}ms` latency with `{shard_servers} servers`"

if not interaction.guild:
await interaction.send(embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))
else:
guild_shard = interaction.guild.shard_id
guildspecshard = self.client.get_shard(guild_shard)
guild_shard_servers = len([guild for guild in self.client.guilds if guild.shard_id == guild_shard])
await interaction.send(f"This server's shard is shard **{guild_shard+1}** with `{round(guildspecshard.latency*100)}ms` and `{guild_shard_servers} servers`", embed=nextcord.Embed(title="Simple Verification Shard Information", description=f"All current shards:\n {description}", colour=COLOUR_MAIN))


@nextcord.slash_command(name="debug", description="Get information useful for debugging")
@cooldowns.cooldown(1,10, bucket=cooldowns.SlashBucket.channel)
async def _debug(self, interaction:Interaction):
await interaction.response.defer()
await interaction.send(f"**Guild ID:** {interaction.guild.id}\n**Channel ID:** {interaction.channel.id}")


def setup(client: commands.Bot):
client.add_cog(Misc(client))
Loading