Fixed minor bugs

main
supopur 2 years ago
parent bad8460276
commit 0097d0557c

@ -1,32 +0,0 @@
import discord, datetime
from discord.ext import commands
class Greetings(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.slash_command(guild_ids=["823188238260633600"])
async def hello(self, ctx):
self.bot.api.logger("inf", "hello from the cog!")
await ctx.send(f'Hello {ctx.author}')
@commands.slash_command(guild_ids=["823188238260633600"])
async def uptime(self, ctx):
#Extends the 3s limit to reply so we dont get a unknown interation error.
await ctx.defer()
#References the api
api = self.bot.api
#Logs something using the api
api.logger("inf", "example.py: Getting uptime...")
#Gets the seconds of how long the root of the bot is runnig
uptime = api.uptime()
#Converts it into a HH:MM:SS format thats more readable. Also the .split makes sure that there are no ms
uptime = str(datetime.timedelta(seconds=uptime)).split(".")[0]
#Sends a follow up
await ctx.followup.send(f"The uptime in H:MM:SS format: {uptime}")
def setup(bot):
bot.add_cog(Greetings(bot))

@ -14,4 +14,5 @@ key = "/path/to/private.key"
[bot]
cogs=["cogs.example", "cogs.web.web", "cogs.sapi.sapi"]
cogs=["cogs.example", "cogs.web.web"]
guild_ids=["823188238260633600", "1081319631463133185", "903933566612799579"]

@ -12,7 +12,7 @@ else:
logging.getLogger().addHandler(logging.StreamHandler())
try:
os.remove("latest.log")
os.remove("main.log")
except: pass
def log(level, log):
if level == "inf":
@ -67,7 +67,7 @@ class API:
except Exception as e:
self.log("err", f"Failed to save to config.toml. {e}")
return 1
#Connect the main .log file to the api so plugins can log to latest.log w/o risking corrupting the file.
#Connect the main .log file to the api so plugins can log to latest.log w/o risking corrupting the file. Absolutly useless as you can do: self.bot.api.logger("inf", "Hello w/o some useless function")
def log(self, status, log):
self.logger(str(status), str(log))
@ -141,7 +141,7 @@ class API:
self.config = config
self.bot = bot
self.logger = log
self.guild_ids = config["bot"]["guild_ids"]
print(type(config["bot"]))
#Load all the extensions
@ -160,7 +160,7 @@ async def on_ready():
@bot.slash_command(guild_ids=["823188238260633600"])
@bot.slash_command(guild_ids=config["bot"]["guild_ids"])
async def stop(ctx):
await ctx.defer()
if ctx.author.guild_permissions.administrator:

Loading…
Cancel
Save