Browse Source

I fucking hate my life. Have to rewrite a cog I already made. Here is the first broken command of the remake. Kill me. Also change avatar gets a remake

tags/v0.4.0
roxie 7 years ago
parent
commit
b3d7b898da
3 changed files with 34 additions and 3 deletions
  1. +4
    -3
      cogs/Admin.py
  2. +29
    -0
      cogs/Misc.py
  3. +1
    -0
      cogs/__init__.py

+ 4
- 3
cogs/Admin.py View File

@@ -166,9 +166,10 @@ class Admin():
thing = url.strip('<>')

avaimg = 'avaimg.png'
async with aiohttp.ClientSession().get(thing) as img:
with open(avaimg, 'wb') as f:
f.write(await img.read())
async with aiohttp.ClientSession() as session:
with session.get(thing) as img:
with open(avaimg, 'wb') as f:
f.write(await img.read())
with open(avaimg, 'rb') as f:
await self.bot.edit_profile(avatar=f.read())
os.remove(avaimg)

+ 29
- 0
cogs/Misc.py View File

@@ -0,0 +1,29 @@
import os
import aiohttp
import discord
from discord.ext.commands import bot

class Misc():
def __init__(self, Bot):
self.bot = Bot

@bot.command(pass_context=True)
async def avatar(self, ctx, user: discord.User = None):
if ctx.message.mentions:
user = ctx.message.mentions[0]
elif not user:
user = ctx.message.author

url = user.avatar_url
avaimg = 'avaimg.webp'

async with aiohttp.ClientSession() as session:
async with session.get(url) as img:
with open(avaimg, 'wb') as f:
f.write(await img.read())
with open(avaimg, 'rb') as f:
await self.bot.send_file(ctx.message.channel, f.read())
os.remove(avaimg)

def setup(Bot):
Bot.add_cog(Misc(Bot))

+ 1
- 0
cogs/__init__.py View File

@@ -4,5 +4,6 @@ cogs = [
'cogs.selfAssign',
'cogs.Fun',
'cogs.joinLeave',
'cogs.Misc',
'config.config'
]

Loading…
Cancel
Save