Skip to content

Commit 7dfc28d

Browse files
Merge branch 'rewrite' into rewrite
2 parents eaeee9c + a77be08 commit 7dfc28d

File tree

3 files changed

+68
-124
lines changed

3 files changed

+68
-124
lines changed

cogs/channels.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def get_news_role(ctx, channel: discord.TextChannel = None):
1717
ch = channel if channel else ctx.channel
1818
return utils.find(lambda r: r.name.startswith(ch.name.split('_')[1]), ctx.guild.roles)
1919

20+
'''
21+
# Commented out. Insights competition among the libraries. Will re-evaluate usage.
2022
@commands.command()
2123
async def leaderboard(self, ctx):
2224
roles = [(r.name, len(r.members)) for r in ctx.guild.roles if 'news' in r.name]
@@ -25,6 +27,7 @@ async def leaderboard(self, ctx):
2527
for i, r in enumerate(roles):
2628
embed.add_field(name=f"{i + 1}. {r[0]}", value=f"**Subscribers:** {r[1]}")
2729
await ctx.send(embed=embed)
30+
'''
2831

2932
@commands.command()
3033
async def subscribe(self, ctx, channel: discord.TextChannel = None):

cogs/data.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class Data:
88
def __init__(self):
99
self.connector = sqlite3.connect('storage.db')
1010
self.modEntry = self.ModEntry(self)
11-
self.verificationEntry = self.VerificationEntry(self)
1211
self.taggingEntry = self.TaggingEntry(self)
1312

1413
# Setup 'modLogs' Databases if isn't valid
@@ -26,19 +25,6 @@ def __init__(self):
2625
except Exception as error:
2726
pass # Database table is already created
2827

29-
# Setup 'verification' Database if isn't valid
30-
try:
31-
# verification table container
32-
connector.execute('''CREATE TABLE verification (
33-
DISCORDID BIGINT NOT NULL,
34-
USERNAME TEXT NOT NULL,
35-
USERID INTEGER NOT NULL,
36-
DATE TEXT NOT NULL
37-
);''')
38-
39-
except Exception as error:
40-
pass # Database table is already created
41-
4228
# Setup 'tagging' Database if isn't valid
4329
try:
4430
# Tagging table container
@@ -105,51 +91,6 @@ def update(self, id, **kwargs):
10591
return False
10692
return True
10793

108-
class VerificationEntry:
109-
110-
def __init__(self, data):
111-
self.Data = data
112-
self.connector = data.connector
113-
self.cursor = self.connector.cursor()
114-
115-
def insert(self, discordid, username, userid, date):
116-
try:
117-
self.cursor.execute(
118-
'''INSERT INTO verification (DISCORDID, USERNAME, USERID, DATE) VALUES (?, ?, ?, ?);''',
119-
(discordid, username, userid, date))
120-
self.connector.commit()
121-
except sqlite3.Error as error:
122-
print(f'{error}')
123-
124-
def fetch(self, id):
125-
index = 0
126-
try:
127-
self.cursor.execute('''SELECT * FROM verification''')
128-
except sqlite3.Error as error:
129-
print(f'{error}')
130-
131-
for discordid, username, userid, date in self.cursor.fetchall():
132-
index += 1
133-
if int(discordid) == id:
134-
return {
135-
"index": index,
136-
"discordid": discordid,
137-
"username": username,
138-
"userid": userid,
139-
"date": date
140-
}
141-
142-
def check_discordid(self, value):
143-
try:
144-
self.cursor.execute('''SELECT * FROM verification''')
145-
for discordid, username, userid, date in self.cursor.fetchall():
146-
if discordid == value:
147-
return True
148-
return False
149-
except sqlite3.Error as error:
150-
print(f'{error}')
151-
return False
152-
15394
class TaggingEntry:
15495

15596
def __init__(self, data):
@@ -224,4 +165,4 @@ def check_identifier(self, identifier):
224165
return False
225166
except sqlite3.Error as error:
226167
print(f'{error}')
227-
return False
168+
return False

main.py

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
import os
2-
import traceback
3-
4-
import discord
5-
from discord.ext import commands
6-
7-
from dotenv import load_dotenv
8-
9-
from embed import default_embed
10-
11-
load_dotenv()
12-
13-
# A list containing all cogs that we want to load
14-
available_cogs = ['cogs.maintenance', 'cogs.logging', 'cogs.utility', 'cogs.channels', 'cogs.moderation',
15-
'cogs.tagging']
16-
17-
# Disabled Cogs
18-
# 'cogs.verification'
19-
20-
# Bot Init
21-
description = "Roblox API Server Documentation Bot"
22-
intent = discord.Intents.default()
23-
intent.members = True
24-
bot = commands.Bot(command_prefix='?', description=description, help_command=None)
25-
26-
27-
# Client Login
28-
@bot.event
29-
async def on_ready():
30-
print(f"Logged in as {bot.user.name}, id: {bot.user.id}")
31-
print("--")
32-
33-
34-
# Event Error. the args are required
35-
@bot.event
36-
async def on_error(event, *args, **kwargs):
37-
channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL')))
38-
emb = default_embed('Error (Event)', color=discord.Color.red())
39-
emb.add_field(name="Event", value=event, inline=False)
40-
emb.add_field(name="Traceback", value=traceback.format_exc(), inline=False)
41-
await channel.send(embed=emb)
42-
43-
44-
# Command Error
45-
@bot.event
46-
async def on_command_error(ctx, error):
47-
channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL')))
48-
emb = default_embed('Error (Commands)', color=discord.Color.red())
49-
emb.add_field(name="Error", value=error, inline=False)
50-
emb.add_field(name="Command", value=ctx.command, inline=False)
51-
emb.add_field(name="Message", value=ctx.message.content, inline=False)
52-
await channel.send(embed=emb)
53-
54-
55-
if __name__ == '__main__':
56-
async def prep():
57-
await bot.wait_until_ready()
58-
# Load Cogs in list
59-
for cog in available_cogs:
60-
bot.load_extension(cog)
61-
62-
# Run Bot
63-
bot.loop.create_task(prep())
64-
bot.run(os.getenv("DISCORD_TOKEN"))
1+
import os
2+
import traceback
3+
4+
import discord
5+
from discord.ext import commands
6+
7+
from dotenv import load_dotenv
8+
9+
from embed import default_embed
10+
11+
load_dotenv()
12+
13+
# A list containing all cogs that we want to load
14+
available_cogs = ['cogs.maintenance', 'cogs.logging', 'cogs.utility', 'cogs.channels', 'cogs.moderation',
15+
'cogs.tagging']
16+
17+
# Disabled Cogs
18+
# 'cogs.verification'
19+
20+
# Bot Init
21+
description = "Roblox API Server Documentation Bot"
22+
intent = discord.Intents.default()
23+
intent.members = True
24+
bot = commands.Bot(command_prefix='?', description=description, help_command=None)
25+
26+
27+
# Client Login
28+
@bot.event
29+
async def on_ready():
30+
print(f"Logged in as {bot.user.name}, id: {bot.user.id}")
31+
print("--")
32+
33+
34+
# Event Error. the args are required
35+
@bot.event
36+
async def on_error(event, *args, **kwargs):
37+
channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL')))
38+
emb = default_embed('Error (Event)', color=discord.Color.red())
39+
emb.add_field(name="Event", value=event, inline=False)
40+
emb.add_field(name="Traceback", value=traceback.format_exc(), inline=False)
41+
await channel.send(embed=emb)
42+
43+
44+
# Command Error
45+
@bot.event
46+
async def on_command_error(ctx, error):
47+
channel = bot.get_channel(int(os.getenv('ERROR_LOGS_CHANNEL')))
48+
emb = default_embed('Error (Commands)', color=discord.Color.red())
49+
emb.add_field(name="Error", value=error, inline=False)
50+
emb.add_field(name="Command", value=ctx.command, inline=False)
51+
emb.add_field(name="Message", value=ctx.message.content, inline=False)
52+
await channel.send(embed=emb)
53+
54+
55+
if __name__ == '__main__':
56+
async def prep():
57+
await bot.wait_until_ready()
58+
# Load Cogs in list
59+
for cog in available_cogs:
60+
bot.load_extension(cog)
61+
62+
# Run Bot
63+
bot.loop.create_task(prep())
64+
bot.run(os.getenv("DISCORD_TOKEN"))

0 commit comments

Comments
 (0)