mirror of https://github.com/stijndcl/didier
Unpack shuffle shortcut too, cleans up code
parent
6a671a4768
commit
3f8f34aa9f
|
@ -23,7 +23,7 @@ class Random(commands.Cog):
|
||||||
|
|
||||||
@commands.command(name="Shuffle", usage="[Argumenten]")
|
@commands.command(name="Shuffle", usage="[Argumenten]")
|
||||||
async def _shuffle(self, ctx, *options):
|
async def _shuffle(self, ctx, *options):
|
||||||
await self.shuffle(ctx, options)
|
await self.shuffle(ctx, *options)
|
||||||
|
|
||||||
@commands.group(name="Random", aliases=["R", "Rand", "RNG"], case_insensitive=True, invoke_without_command=True)
|
@commands.group(name="Random", aliases=["R", "Rand", "RNG"], case_insensitive=True, invoke_without_command=True)
|
||||||
@help.Category(category=Category.Random, unpack=True)
|
@help.Category(category=Category.Random, unpack=True)
|
||||||
|
@ -33,8 +33,7 @@ class Random(commands.Cog):
|
||||||
@random.command(name="Choice", usage="[Argumenten]")
|
@random.command(name="Choice", usage="[Argumenten]")
|
||||||
async def choice(self, ctx, *options):
|
async def choice(self, ctx, *options):
|
||||||
if not options or not options[0]:
|
if not options or not options[0]:
|
||||||
await ctx.send("Geef een geldige reeks op.")
|
return await ctx.send("Geef een geldige reeks op.")
|
||||||
return
|
|
||||||
|
|
||||||
await ctx.send(random.choice(options))
|
await ctx.send(random.choice(options))
|
||||||
|
|
||||||
|
@ -69,8 +68,7 @@ class Random(commands.Cog):
|
||||||
try:
|
try:
|
||||||
identity = requests.get("https://randomuser.me/api/").json()
|
identity = requests.get("https://randomuser.me/api/").json()
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
await ctx.send("Er ging iets mis. Probeer het opnieuw.")
|
return await ctx.send("Er ging iets mis. Probeer het opnieuw.")
|
||||||
return
|
|
||||||
|
|
||||||
identity = identity["results"][0]
|
identity = identity["results"][0]
|
||||||
name = identity["name"]
|
name = identity["name"]
|
||||||
|
@ -87,12 +85,7 @@ class Random(commands.Cog):
|
||||||
@random.command(name="Shuffle", aliases=["Order"], usage="[Argumenten]")
|
@random.command(name="Shuffle", aliases=["Order"], usage="[Argumenten]")
|
||||||
async def shuffle(self, ctx, *args):
|
async def shuffle(self, ctx, *args):
|
||||||
if not args:
|
if not args:
|
||||||
await ctx.send("Geef een geldige reeks op.")
|
return await ctx.send("Geef een geldige reeks op.")
|
||||||
return
|
|
||||||
|
|
||||||
# Allows shuffle alias to pass in it's args too
|
|
||||||
if isinstance(args[0], tuple):
|
|
||||||
args = args[0]
|
|
||||||
|
|
||||||
args = list(args)
|
args = list(args)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue