Accept black
code reformats
This commit is contained in:
parent
ca3d136126
commit
757b31fe4e
@ -28,7 +28,7 @@ class MyBot(commands.Bot):
|
|||||||
|
|
||||||
bot = MyBot()
|
bot = MyBot()
|
||||||
bot.remove_command("help")
|
bot.remove_command("help")
|
||||||
bot.temp_command_count = {} # command_name: count
|
bot.temp_command_count = {} # command_name: count
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
@ -11,9 +11,11 @@ class Stats(commands.Cog):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
def cog_load(self):
|
def cog_load(self):
|
||||||
connection = sqlite3.connect('count.db')
|
connection = sqlite3.connect("count.db")
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute("CREATE TABLE IF NOT EXISTS count (command_name, count, PRIMARY KEY (command_name))")
|
cursor.execute(
|
||||||
|
"CREATE TABLE IF NOT EXISTS count (command_name, count, PRIMARY KEY (command_name))"
|
||||||
|
)
|
||||||
connection.commit()
|
connection.commit()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
@ -21,20 +23,25 @@ class Stats(commands.Cog):
|
|||||||
|
|
||||||
@tasks.loop(seconds=30)
|
@tasks.loop(seconds=30)
|
||||||
async def dump_count(self):
|
async def dump_count(self):
|
||||||
connection = sqlite3.connect('count.db')
|
connection = sqlite3.connect("count.db")
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
for command_name, count in self.bot.temp_command_count.items():
|
for command_name, count in self.bot.temp_command_count.items():
|
||||||
try:
|
try:
|
||||||
cursor.execute("INSERT INTO count (command_name, count) VALUES (?, ?)", (command_name, count))
|
cursor.execute(
|
||||||
|
"INSERT INTO count (command_name, count) VALUES (?, ?)",
|
||||||
|
(command_name, count),
|
||||||
|
)
|
||||||
except sqlite3.IntegrityError:
|
except sqlite3.IntegrityError:
|
||||||
cursor.execute("UPDATE count SET count = count + ? WHERE command_name = ?", (count, command_name))
|
cursor.execute(
|
||||||
|
"UPDATE count SET count = count + ? WHERE command_name = ?",
|
||||||
|
(count, command_name),
|
||||||
|
)
|
||||||
|
|
||||||
connection.commit()
|
connection.commit()
|
||||||
connection.close()
|
connection.close()
|
||||||
self.bot.temp_command_count = {}
|
self.bot.temp_command_count = {}
|
||||||
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_app_command_completion(self, interaction, command):
|
async def on_app_command_completion(self, interaction, command):
|
||||||
try:
|
try:
|
||||||
@ -42,18 +49,14 @@ class Stats(commands.Cog):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
self.bot.temp_command_count[interaction.command.name] = 1
|
self.bot.temp_command_count[interaction.command.name] = 1
|
||||||
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.dm_only()
|
@commands.dm_only()
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def stats(self, ctx: commands.Context):
|
async def stats(self, ctx: commands.Context):
|
||||||
connection = sqlite3.connect('count.db')
|
connection = sqlite3.connect("count.db")
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(title="Command Statistics", color=BOT_COLOR)
|
||||||
title="Command Statistics",
|
|
||||||
color=BOT_COLOR
|
|
||||||
)
|
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
data = cursor.execute("SELECT * FROM count").fetchall()
|
data = cursor.execute("SELECT * FROM count").fetchall()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user