added folder setup to pokemon extension
This commit is contained in:
parent
2b0ec090c4
commit
f19e996560
2 changed files with 14 additions and 8 deletions
|
|
@ -6,9 +6,8 @@ import os
|
|||
import json
|
||||
import math
|
||||
import time
|
||||
import aiohttp
|
||||
|
||||
class Pokemon(commands.Cog):
|
||||
class PokemonGame(commands.Cog):
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
|
@ -16,9 +15,17 @@ class Pokemon(commands.Cog):
|
|||
self.data_dir = "data/pokemon/"
|
||||
self.folder_setup()
|
||||
|
||||
def folder_setup(self):
|
||||
try:
|
||||
if not os.path.exists(self.working_dir):
|
||||
os.mkdir(self.working_dir)
|
||||
if not os.path.exists(self.data_dir):
|
||||
os.mkdir(self.data_dir)
|
||||
except:
|
||||
print("PokemonGame failed to make directories")
|
||||
|
||||
async def get_json(self, url):
|
||||
http_session = aiohttp.ClientSession()
|
||||
async with http_session.get(url) as resp:
|
||||
async with self.bot.http_session.get(url) as resp:
|
||||
json_data = await resp.json()
|
||||
return json_data
|
||||
|
||||
|
|
@ -275,4 +282,4 @@ class Pokemon(commands.Cog):
|
|||
await ctx.channel.send(message)
|
||||
|
||||
async def setup(bot):
|
||||
bot.add_cog(Pokemon)
|
||||
await bot.add_cog(PokemonGame(bot))
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@ ftp_public_html = os.getenv('ftp_public_html')
|
|||
#discord setup START
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
bot = commands.Bot(command_prefix='!', intents=intents)
|
||||
bot = commands.Bot(command_prefix='?', intents=intents)
|
||||
#discord setup END
|
||||
|
||||
|
||||
|
||||
async def handle_error(error):
|
||||
print(error)
|
||||
current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||
|
|
@ -243,7 +242,7 @@ async def on_message(ctx):
|
|||
|
||||
await react_to_msg(ctx, channel_vars["react_to_msgs"]) #emoji reactions
|
||||
|
||||
if channel_vars["commands_enabled"] or (ctx.author.id == 242018983241318410 and ctx.content[0] == "!"):
|
||||
if channel_vars["commands_enabled"] or (ctx.author.id == 242018983241318410 and ctx.content[0] == "?"):
|
||||
await bot.process_commands(ctx)
|
||||
if not channel_vars["commands_enabled"]:
|
||||
await ctx.channel.send("This command only ran because you set it to allow to run even when commands are disabled")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue