Skip to content

Commit

Permalink
removed text folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruvacube committed Feb 2, 2022
1 parent 1b8ef05 commit 028f30f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 303 deletions.
2 changes: 1 addition & 1 deletion minato_namikaze/cogs/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ async def on_guild_join(self, guild):
file = discord.File(img[-1], filename=img[0])

f = open(
BASE_DIR / join("lib", "text", "welcome_message.txt"),
BASE_DIR / join("lib", "data", "welcome_message.txt"),
"r",
)

Expand Down
3 changes: 3 additions & 0 deletions minato_namikaze/discordbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ async def on_shard_resumed(self, shard_id):
self.resumes[shard_id].append(discord.utils.utcnow())

async def close(self):
import shutil
if not os.path.isdir(api_image_store_dir):
shutil.rmtree(api_image_store_dir)
await super().close()

async def process_commands(self, message):
Expand Down
12 changes: 5 additions & 7 deletions minato_namikaze/lib/functions/meek_moe.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
from os.path import join
from pathlib import Path
from random import choice
import gzip

import aiohttp

from ..classes.embed import Embed, ErrorEmbed

with gzip.open(join(Path(__file__).resolve().parent.parent,"data","vocaloid_images.txt.gz",), "rt",encoding="utf-8") as f:
imageslist: list = f.readlines()

async def meek_api(name: str):
session = aiohttp.ClientSession()

l = (choice([
"https://api.meek.moe/", "https://miku-for.us/api/v2/random", False
"https://api.meek.moe/", False
]) if name.lower() == "miku" else "https://api.meek.moe/")
e = Embed(title=name.capitalize())
try:
if name == "miku" and l:
data = await session.get(l + name if l == "https://api.meek.moe/"
else "https://miku-for.us/api/v2/random")
data = await session.get(l + name if l == "https://api.meek.moe/" else "https://api.meek.moe/")
url = await data.json()
else:
data = await session.get(l + name)
url = await data.json()
e.set_image(url=url["url"])
except:
imageslistdir = Path(__file__).resolve(
strict=True).parent.parent / join("text", "vocaloid_images.txt")
filepointer = open(imageslistdir)
imageslist = filepointer.readlines()
if name == "miku":
e.set_image(url=choice(imageslist))
else:
Expand Down
262 changes: 0 additions & 262 deletions minato_namikaze/lib/text/images_list.txt

This file was deleted.

26 changes: 0 additions & 26 deletions minato_namikaze/lib/text/vocaloid_images.txt

This file was deleted.

17 changes: 10 additions & 7 deletions minato_namikaze/lib/util/post_user_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@

import aiohttp
import requests
import gzip

from ..classes.embed import Embed
from .vars import *


class PostStats:
def __init__(self, bot):
self.bot = bot

@staticmethod
def imagelist(self):
with gzip.open(join(Path(__file__).resolve().parent.parent,"data","vocaloid_images.txt.gz",), "rt",encoding="utf-8") as f:
images_list: list = f.readlines()
return images_list

async def delete_commands(self):
try:
Expand All @@ -24,8 +30,8 @@ async def delete_commands(self):
},
)
if allcmd.status_code != 404:
for i in allcmd1:
for j in allcmd1.get(i):
for i in allcmd:
for j in allcmd.get(i):
requests.delete(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands/{j.get("id")}',
headers={
Expand Down Expand Up @@ -142,10 +148,7 @@ async def post_guild_stats_all(self):
guildsno = len(self.bot.guilds)
members = len(set(self.bot.get_all_members()))

imageslistdir = Path(__file__).resolve(
strict=True).parent.parent / join("text", "images_list.txt")
filepointer = open(imageslistdir)
imageslist = filepointer.readlines()
imageslist = self.imagelist
shards = 1

a = await self.post(
Expand Down

0 comments on commit 028f30f

Please sign in to comment.