Replaces asyncio coroutines with native async
Replaces @asyncio.coroutine decorator with async Replaces yield from with await
This commit is contained in:
+12
-17
@@ -1,4 +1,3 @@
|
||||
import asyncio
|
||||
import discord
|
||||
import os
|
||||
import praw
|
||||
@@ -30,18 +29,17 @@ class General(commands.Cog):
|
||||
return embed
|
||||
|
||||
@commands.command()
|
||||
@asyncio.coroutine
|
||||
def huge(self, ctx, *, arg):
|
||||
async def huge(self, ctx, *, arg):
|
||||
"""YUGE. Geeft een grote versie van de gegeven emoji terug. Werkt alleen voor custom emoji.
|
||||
Bijvoorbeeld:
|
||||
!huge :ancilla:
|
||||
"""
|
||||
em = self.get_emoji_embed(arg)
|
||||
try:
|
||||
yield from ctx.message.delete()
|
||||
await ctx.message.delete()
|
||||
except:
|
||||
print("No permission to delete message")
|
||||
yield from ctx.channel.send(ctx.author.mention, embed=em)
|
||||
await ctx.channel.send(ctx.author.mention, embed=em)
|
||||
|
||||
def get_aww_post(self):
|
||||
raww = self.r.subreddit('aww+catloaf+tuckedinkitties+babyelephantgifs+babybigcatgifs+blep+holdmynip+gingerkitty+cathighfive+catsstandingup+catsareassholes+eyebleach')
|
||||
@@ -49,15 +47,14 @@ class General(commands.Cog):
|
||||
return random.choice(listing)
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@asyncio.coroutine
|
||||
def aww(self, ctx):
|
||||
async def aww(self, ctx):
|
||||
""" iets schattigs... """
|
||||
post = self.get_aww_post()
|
||||
try:
|
||||
yield from ctx.message.delete()
|
||||
await ctx.message.delete()
|
||||
except:
|
||||
print("No permission to delete message")
|
||||
yield from ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
||||
await ctx.channel.send(ctx.author.mention + ' ' + post.url)
|
||||
|
||||
def get_kopieerpasta(self):
|
||||
rkopieerpasta = self.r.subreddit('kopieerpasta')
|
||||
@@ -71,8 +68,7 @@ class General(commands.Cog):
|
||||
return post
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@asyncio.coroutine
|
||||
def kopieerpasta(self, ctx):
|
||||
async def kopieerpasta(self, ctx):
|
||||
"""Een willekeurige shitpost"""
|
||||
post = self.get_kopieerpasta()
|
||||
print(post.url)
|
||||
@@ -83,23 +79,22 @@ class General(commands.Cog):
|
||||
print(post.url)
|
||||
a += 1
|
||||
try:
|
||||
yield from ctx.message.delete()
|
||||
await ctx.message.delete()
|
||||
except:
|
||||
print("No permission to delete message")
|
||||
|
||||
if len(post.selftext + post.title) < 1990:
|
||||
yield from ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
||||
await ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
||||
else:
|
||||
yield from ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
||||
await ctx.channel.send("Geen kopieerpasta voor jou vandaag.")
|
||||
|
||||
def get_playlist_json(self):
|
||||
return requests.get(self.muzak_url + '/stroopwafel')
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@asyncio.coroutine
|
||||
def playlist(self, ctx):
|
||||
async def playlist(self, ctx):
|
||||
"""HDcon2021 playlist"""
|
||||
data = json.loads(self.get_playlist_json().content)
|
||||
msg = 'Stemmen en nomineren kan hier: {}\n'.format(self.muzak_url)
|
||||
msg += '*Er zijn al {} nummers genomineerd*\n'.format(data['stemCount'])
|
||||
yield from ctx.channel.send(msg)
|
||||
await ctx.channel.send(msg)
|
||||
|
||||
Reference in New Issue
Block a user