Merge pull request #36 from stijndcl/pin

Close small issues
pull/45/head
Stijn De Clercq 2021-02-08 22:22:13 +01:00 committed by GitHub
commit a9c8d31ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 22 deletions

View File

@ -111,6 +111,10 @@ class Events(commands.Cog):
# Someone used a command that was on cooldown
elif isinstance(err, commands.CommandOnCooldown):
await ctx.send("Je kan dit commando niet (meer) spammen.", delete_after=10)
elif isinstance(err, commands.MessageNotFound):
await ctx.send("Geen message gevonden die overeenkomt met het opgegeven argument.")
elif isinstance(err, (commands.ChannelNotFound, commands.ChannelNotReadable)):
await ctx.send("Geen channel gevonden dat overeenkomt met het opgegeven argument.")
# Someone forgot an argument or passed an invalid argument
elif isinstance(err, (commands.BadArgument, commands.MissingRequiredArgument)):
await ctx.send("Controleer je argumenten.")

View File

@ -30,7 +30,7 @@ class Minesweeper(commands.Cog):
dimensions = {
"e": [5, 5, 4],
"m": [10, 10, 20],
"h": [13, 13, 35]
"h": [13, 8, 35]
}
numbers = {

View File

@ -96,9 +96,8 @@ class Oneliners(commands.Cog):
@commands.command(name="Changelog", aliases=["Cl", "Change", "Changes"])
@help.Category(category=Category.Didier)
async def changelog(self, ctx, *args):
await ctx.send("V2.0: <https://docs.google.com/document/d/1oa-9oc9yFnZ0X5sLJTWfdahtaL0vF8acLl-xMXA3a40/edit#>\n"
"V2.1: https://docs.google.com/document/d/1ezdJBTnKWoog4q9yJrgwfF4iGOn-PZMoBZgSNVYPtqg/edit#")
async def changelog(self, ctx):
await ctx.send("v2.3.0: https://github.com/stijndcl/didier/releases/tag/2.3.0")
@commands.command(name="Todo", aliases=["List", "Td"])
@help.Category(category=Category.Didier)

View File

@ -19,25 +19,16 @@ class ReactWord(commands.Cog):
@help.Category(category=Category.Other)
async def react(self, ctx, *words):
words = list(words)
message = ctx.message
target = False
channel = ctx.channel
# Check if the URL or the Id was passed
if str(words[-1]).count("/") > 3:
spl = str(words[-1]).split("/")
channel = self.client.get_channel(int(spl[-2]))
if channel is None:
return await ctx.send("Ik kan geen kanaal zien met dit id.")
words[-1] = spl[-1]
# Get the message object if an Id was passed, otherwise react to the message itself
try:
message = await channel.fetch_message(words[-1])
if message is None:
return await ctx.send("Ik kan geen bericht zien met dit id.")
# Message id or URL passed as final argument
if (len(words[-1]) == 18 and all(i.isdigit() for i in words[-1])) or "discord.com/channels/" in words[-1]:
target = True
except discord.HTTPException:
message = ctx.message
message = await commands.MessageConverter().convert(ctx, words[-1])
# Cut id or URL
words = words[:-1]
# Reactions that were added before this command was executed
previousReactions = ([x.emoji for x in message.reactions]) if len(message.reactions) != 0 else []

View File

@ -84,6 +84,18 @@ class School(commands.Cog):
schedule.append(val)
return schedule
@commands.command(name="Pin", usage="[Message]")
@help.Category(category=Category.School)
async def pin(self, ctx, message: discord.Message):
# In case people abuse, check if they're blacklisted
blacklist = []
if ctx.author.id in blacklist:
return
await ctx.message.add_reaction("")
await message.pin(reason="Didier Pin door {}".format(ctx.author.display_name))
def setup(client):
client.add_cog(School(client))

View File

@ -20,6 +20,11 @@ class Ba2(Enum):
FuncProg = {"year": 2, "semester": 1, "id": 727879279622225920, "name": "Functioneel Programmeren"}
StatProb = {"year": 2, "semester": 1, "id": 727879946458103880, "name": "Statistiek en Probabiliteit"}
SysProg = {"year": 2, "semester": 1, "id": 727880036644028517, "name": "Systeemprogrammeren"}
CompArch = {"year": 2, "semester": 2, "id": 807565108355137566, "name": "Computerarchitectuur"}
Multimedia = {"year": 2, "semester": 2, "id": 807565458496028683, "name": "Multimedia"}
SEL1 = {"year": 2, "semester": 2, "id": 807565600086818817, "name": "Software Engineering Lab 1"}
WebDev = {"year": 2, "semester": 2, "id": 807565717234778132, "name": "Webdevelopment"}
WetRek = {"year": 2, "semester": 2, "id": 807562607707947058, "name": "Wetenschappelijk Rekenen"}
years = [Ba1, Ba2]

View File

@ -68,6 +68,7 @@
"muttn": "Kiekt oeveel van ne muttn da [@Persoon] wel nie es aje eenen tagt, anders ist uzelf.",
"neck": "<:WhatDidYou:744476950654877756><:DoTo:744476965951504414><:MyDrink:744476979939508275>",
"nightly": "Daily is overrated.\nClaim jouw dagelijkse bonus Didier Dinks.",
"pin": "Pin [Message] zodat je geen admins hoeft te pingen. Misbruik kan je blacklisten.",
"pjoke": "Didier vertelt een programming joke.",
"poke": "Tik [Persoon].",
"poke blacklist": "Indien je liever niet aan Poke wil deelnemen, kan je jezelf op deze manier blacklisten.\nIndien je jezelf wil ont-blacklisten stuur je een DM naar DJ STIJN (om misbruik tegen te gaan).",

View File

@ -147,7 +147,7 @@ def getTable():
formatted = [_formatRow(row) for row in rows]
header = "Jupiler Pro League Klassement"
table = tabulate.tabulate(formatted, headers=["#", "Ploeg", "Punten", "M", "M+", "M-", "M="])
table = tabulate.tabulate(formatted, headers=["#", "Ploeg", "Punten", "M", "M+", "M-", "M=", "D+", "D-", "D+/-"])
return "```{}\n\n{}```".format(header, table)
@ -156,7 +156,7 @@ def _formatRow(row):
"""
Function that formats a row into a list for Tabulate to use
"""
scoresArray = list([td.renderContents().decode("utf-8") for td in row.find_all("td")])[:6]
scoresArray = list([td.renderContents().decode("utf-8") for td in row.find_all("td")])[:9]
# Insert the team name into the list
scoresArray.insert(1, row.find_all("a")[0].renderContents().decode("utf-8").split("<!--")[0])

View File

@ -3,6 +3,10 @@ def check(content, earlier=[]):
if len(content) < 1:
return False, ["Controleer je argumenten."]
# More than 20 reacts queried
if len("".join(content)) + len(earlier) > 20:
return False, ["Er kunnen maximaal 20 emoji's op een message geplaatst worden."]
# This command should work case insensitive
for i, word in enumerate(content):
content[i] = word.lower()