Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
925e908865 | ||
|
|
ce23527eee | ||
|
|
84287234e2 | ||
|
|
56f90e7829 | ||
|
|
38877451c5 | ||
|
|
b3efbaa291 |
No files matched your search
@@ -1,12 +1,12 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from pprint import pprint
|
||||
import time
|
||||
import numpy as np
|
||||
import random
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class Points(commands.Cog):
|
||||
"""Geef elkaar punten!"""
|
||||
|
||||
@@ -23,15 +23,36 @@ class Points(commands.Cog):
|
||||
def __check(self, ctx):
|
||||
return True
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def geefpunten(self, ctx, user, points: int):
|
||||
@commands.command()
|
||||
async def geefpunten(self, ctx, *args):
|
||||
"""Wees eens lief. Geef iemand wat punten.
|
||||
Bijvoorbeeld:
|
||||
!geefpunten @ikbenjp 42
|
||||
!geefpunten @ikbenjp 42 of !geefpunten 42 @ikbenjp
|
||||
Let op: je moet iemand taggen om punten uit te delen
|
||||
De eerste 10 punten zijn on the house. (Als er genoeg in de bank zit.)
|
||||
"""
|
||||
|
||||
if not ctx.message.mentions: #als er uberhaupt geen mention is zijn we snel klaar
|
||||
await ctx.send(f"{ctx.author.mention} je moet iemand taggen om punten te geven. :)")
|
||||
return
|
||||
|
||||
if len(args) == 2:
|
||||
user = None
|
||||
points = None
|
||||
for arg in args[0:2]:
|
||||
if arg[0:2] == "<@":
|
||||
user = arg #doen we verder niks mee, maar zo bepalen we positie van de puntjes
|
||||
else:
|
||||
try:
|
||||
points = int(arg)
|
||||
except ValueError:
|
||||
pass #dealen we hieronder mee
|
||||
|
||||
if user == None or points == None:
|
||||
raise commands.BadArgument("Verkeerd type argumenten")
|
||||
else:
|
||||
raise commands.BadArgument("Verkeerd aantal argumenten")
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
if points == 0:
|
||||
@@ -41,11 +62,6 @@ class Points(commands.Cog):
|
||||
await self.sendErrorDm(ctx, "Daar hebben we de !neempunten functie voor. Voor meer info typ: ```!help neempunten```")
|
||||
return
|
||||
|
||||
if user[0:2] != "<@":
|
||||
await self.sendErrorDm(ctx, "Je moet iemand taggen om punten te geven. :)")
|
||||
#TODO ook userId oid toestaan?
|
||||
return
|
||||
|
||||
userObj = ctx.message.mentions[0]
|
||||
|
||||
if userObj.id == ctx.author.id:
|
||||
@@ -83,15 +99,36 @@ class Points(commands.Cog):
|
||||
self.transferPoints(giverId, recieverId, remainingPointsToGive)
|
||||
|
||||
|
||||
@commands.command(pass_context=True, hidden=False)
|
||||
async def neempunten(self, ctx, user, points: int):
|
||||
@commands.command()
|
||||
async def neempunten(self, ctx, *args):
|
||||
"""Tijd om iemand the shamen. Haal wat punten weg.
|
||||
Bijvoorbeeld:
|
||||
!neempunten @mark 5
|
||||
!neempunten @mark 5 of !neempunten 5 @mark
|
||||
Punten gaan naar de bank. Je mag niet meer dan 10 punten per dag afnemen.
|
||||
Let op: je moet iemand taggen om punten weg te nemen.
|
||||
"""
|
||||
|
||||
if not ctx.message.mentions: #als er uberhaupt geen mention is zijn we snel klaar
|
||||
await ctx.send(f"{ctx.author.mention} je moet iemand taggen om punten af te nemen. :)")
|
||||
return
|
||||
|
||||
if len(args) == 2:
|
||||
user = None
|
||||
points = None
|
||||
for arg in args[0:2]:
|
||||
if arg[0:2] == "<@":
|
||||
user = arg #doen we verder niks mee, maar zo bepalen we positie van de puntjes
|
||||
else:
|
||||
try:
|
||||
points = int(arg)
|
||||
except ValueError:
|
||||
pass #dealen we hieronder mee
|
||||
|
||||
if user == None or points == None:
|
||||
raise commands.BadArgument("Verkeerd type argumenten")
|
||||
else:
|
||||
raise commands.BadArgument("Verkeerd aantal argumenten")
|
||||
|
||||
self.reloadPointsCount()
|
||||
|
||||
if points < 1:
|
||||
@@ -105,10 +142,6 @@ class Points(commands.Cog):
|
||||
await self.sendErrorDm(ctx, "Je mag vandaag nog maar " + str(remainingToTakeAway) + " punten wegnemen.")
|
||||
return
|
||||
|
||||
if user[0:2] != "<@":
|
||||
await self.sendErrorDm(ctx, "Je moet iemand taggen. :)")
|
||||
return
|
||||
|
||||
userObj = ctx.message.mentions[0]
|
||||
|
||||
if not self.isUserOnList(userObj):
|
||||
|
||||
@@ -29,6 +29,21 @@ intents.members = True
|
||||
|
||||
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'), description='Stroopwafel. Shitpost bot extraordinaire.', pm_help=True, intents=intents)
|
||||
|
||||
@bot.event
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.BadArgument):
|
||||
await ctx.send(f"{ctx.author.mention} Onheus gebruik van het commando. Lees de docs nog eens door:")
|
||||
await ctx.send_help(ctx.command)
|
||||
return
|
||||
if isinstance(error, commands.MissingRequiredArgument):
|
||||
await ctx.send(f"{ctx.author.mention} Volgens bij ben je nog iets vergeten toe te voegen aan dit commando. Lees de docs nog eens door:")
|
||||
await ctx.send_help(ctx.command)
|
||||
return
|
||||
if isinstance(error, commands.CommandNotFound):
|
||||
await ctx.send(f"{ctx.author.mention} Vermoedelijk bedoelde je iets anders. Typ !help voor alle opties.")
|
||||
return
|
||||
raise error
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
await add_cogs(bot)
|
||||
|
||||
Reference in new issue
Block a user