mirror of https://github.com/stijndcl/didier
commit
fc1abbffc8
|
@ -97,6 +97,10 @@ class Events(commands.Cog):
|
||||||
:param ctx: Discord Context
|
:param ctx: Discord Context
|
||||||
:param err: the error thrown
|
:param err: the error thrown
|
||||||
"""
|
"""
|
||||||
|
# Zandbak Didier shouldn't spam the error logs
|
||||||
|
if self.client.user.id == int(constants.coolerDidierId):
|
||||||
|
raise err
|
||||||
|
|
||||||
# Don't handle commands that have their own custom error handler
|
# Don't handle commands that have their own custom error handler
|
||||||
if hasattr(ctx.command, 'on_error'):
|
if hasattr(ctx.command, 'on_error'):
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from data import constants
|
||||||
from decorators import help
|
from decorators import help
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -20,6 +21,9 @@ class Faq(commands.Cog):
|
||||||
"""
|
"""
|
||||||
Command group that controls the FAQ commands.
|
Command group that controls the FAQ commands.
|
||||||
When this command is invoked, it sends a list of valid categories.
|
When this command is invoked, it sends a list of valid categories.
|
||||||
|
|
||||||
|
After invoking in a subject's channel (without passing a category),
|
||||||
|
it sends the FAQ for that subject instead.
|
||||||
:param ctx: Discord Context
|
:param ctx: Discord Context
|
||||||
:param args: args passed
|
:param args: args passed
|
||||||
"""
|
"""
|
||||||
|
@ -28,6 +32,10 @@ class Faq(commands.Cog):
|
||||||
if len(args) != 0 and any("@" not in arg for arg in args):
|
if len(args) != 0 and any("@" not in arg for arg in args):
|
||||||
return await self.faqCategory(ctx, args)
|
return await self.faqCategory(ctx, args)
|
||||||
|
|
||||||
|
# Check if the command was used in a subject's channel
|
||||||
|
if ctx.channel.id in constants.faq_channels:
|
||||||
|
return await self.faqCategory(ctx, (constants.faq_channels[ctx.channel.id],))
|
||||||
|
|
||||||
# List of all categories with the first letter capitalized
|
# List of all categories with the first letter capitalized
|
||||||
resp = [stringFormatters.titleCase(cat[0]) for cat in faq.getCategories()]
|
resp = [stringFormatters.titleCase(cat[0]) for cat in faq.getCategories()]
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from data import paginatedLeaderboard
|
||||||
from decorators import help
|
from decorators import help
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -162,10 +163,9 @@ class Fun(commands.Cog):
|
||||||
memeList = [": ".join([stringFormatters.titleCase(meme[1]),
|
memeList = [": ".join([stringFormatters.titleCase(meme[1]),
|
||||||
str(meme[2])]) for meme in sorted(memeList, key=lambda x: x[1])]
|
str(meme[2])]) for meme in sorted(memeList, key=lambda x: x[1])]
|
||||||
|
|
||||||
# Add the fields into the embed
|
pages = paginatedLeaderboard.Pages(source=paginatedLeaderboard.Source(memeList, "Memes", discord.Colour.blue()),
|
||||||
embed = discord.Embed(colour=discord.Colour.blue())
|
clear_reactions_after=True)
|
||||||
embed.add_field(name="Meme: aantal velden", value="\n".join(memeList), inline=False)
|
await pages.start(ctx)
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@commands.command(name="Pjoke")
|
@commands.command(name="Pjoke")
|
||||||
@help.Category(category=Category.Fun)
|
@help.Category(category=Category.Fun)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import math
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO some sort of general leaderboard because all of them are the same
|
# TODO some sort of general leaderboard because all of them are the same
|
||||||
class Leaderboards(commands.Cog):
|
class Leaderboards(commands.Cog):
|
||||||
|
|
||||||
|
@ -156,15 +155,20 @@ class Leaderboards(commands.Cog):
|
||||||
async def messages(self, ctx):
|
async def messages(self, ctx):
|
||||||
s = stats.getAllRows()
|
s = stats.getAllRows()
|
||||||
boardTop = []
|
boardTop = []
|
||||||
|
|
||||||
|
message_count = stats.getTotalMessageCount()
|
||||||
|
|
||||||
for i, user in enumerate(sorted(s, key=lambda x: x[11], reverse=True)):
|
for i, user in enumerate(sorted(s, key=lambda x: x[11], reverse=True)):
|
||||||
if int(user[11]) == 0:
|
if int(user[11]) == 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
perc = round(int(user[11]) * 100 / message_count, 2)
|
||||||
|
|
||||||
name = self.utilsCog.getDisplayName(ctx, user[0])
|
name = self.utilsCog.getDisplayName(ctx, user[0])
|
||||||
if int(user[0]) == int(ctx.author.id):
|
if int(user[0]) == int(ctx.author.id):
|
||||||
boardTop.append("**{} ({:,})**".format(name, round(int(user[11]))))
|
boardTop.append("**{} ({:,} | {}%)**".format(name, round(int(user[11])), perc))
|
||||||
else:
|
else:
|
||||||
boardTop.append("{} ({:,})".format(name, round(int(user[11]))))
|
boardTop.append("{} ({:,} | {}%)".format(name, round(int(user[11])), perc))
|
||||||
await self.startPaginated(ctx, boardTop, "Messages Leaderboard")
|
await self.startPaginated(ctx, boardTop, "Messages Leaderboard")
|
||||||
|
|
||||||
@leaderboard.command(name="Muttn", aliases=["M", "Mutn", "Mutten"], hidden=True)
|
@leaderboard.command(name="Muttn", aliases=["M", "Mutn", "Mutten"], hidden=True)
|
||||||
|
|
|
@ -165,12 +165,12 @@ class ModCommands(commands.Cog):
|
||||||
|
|
||||||
embed.set_author(name=user.display_name, icon_url=user.avatar_url)
|
embed.set_author(name=user.display_name, icon_url=user.avatar_url)
|
||||||
embed.add_field(name="Discriminator", value="#{}".format(user.discriminator))
|
embed.add_field(name="Discriminator", value="#{}".format(user.discriminator))
|
||||||
embed.add_field(name="Discord Id", value=user.id)
|
embed.add_field(name="Discord id", value=user.id)
|
||||||
embed.add_field(name="Bot", value="Nee" if not user.bot else "Ja")
|
embed.add_field(name="Bot", value="Nee" if not user.bot else "Ja")
|
||||||
|
|
||||||
created_local = timeFormatters.epochToDate(user.created_at.timestamp())
|
created_local = timeFormatters.epochToDate(user.created_at.timestamp())
|
||||||
|
|
||||||
embed.add_field(name="Account Aangemaakt", value="{}\n({} geleden)".format(
|
embed.add_field(name="Account aangemaakt", value="{}\n({} geleden)".format(
|
||||||
created_local["date"], timeFormatters.diffYearBasisString(round(created_local["dateDT"].timestamp()))
|
created_local["date"], timeFormatters.diffYearBasisString(round(created_local["dateDT"].timestamp()))
|
||||||
), inline=False)
|
), inline=False)
|
||||||
|
|
||||||
|
@ -178,12 +178,10 @@ class ModCommands(commands.Cog):
|
||||||
if ctx.guild is not None:
|
if ctx.guild is not None:
|
||||||
member_instance = ctx.guild.get_member(user.id)
|
member_instance = ctx.guild.get_member(user.id)
|
||||||
|
|
||||||
embed.add_field(name="Lid van {}".format(ctx.guild.name), value="Nee" if member_instance is None else "Ja")
|
|
||||||
|
|
||||||
if member_instance is not None:
|
if member_instance is not None:
|
||||||
joined_local = timeFormatters.epochToDate(member_instance.joined_at.timestamp())
|
joined_local = timeFormatters.epochToDate(member_instance.joined_at.timestamp())
|
||||||
|
|
||||||
embed.add_field(name="Lid Geworden Op", value="{}\n({} Geleden)".format(
|
embed.add_field(name="Lid geworden van {} op".format(ctx.guild.name), value="{}\n({} Geleden)".format(
|
||||||
joined_local["date"], timeFormatters.diffYearBasisString(round(joined_local["dateDT"].timestamp()))
|
joined_local["date"], timeFormatters.diffYearBasisString(round(joined_local["dateDT"].timestamp()))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,16 @@ class TestCog(commands.Cog):
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
# All commands in this Cog should only be accessible to me
|
|
||||||
def cog_check(self, ctx):
|
def cog_check(self, ctx):
|
||||||
return checks.isMe(ctx)
|
"""
|
||||||
|
Check executed for every command in this cog.
|
||||||
|
|
||||||
|
If necessary, create your own check here. A check is just a function
|
||||||
|
that returns True or False, and takes ctx as an argument. A command will
|
||||||
|
only be executed when this check returns True, which is why that is the default
|
||||||
|
implementation for this function.
|
||||||
|
"""
|
||||||
|
return True
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def test(self, ctx):
|
async def test(self, ctx):
|
||||||
|
|
|
@ -22,9 +22,13 @@ class Xp(commands.Cog):
|
||||||
|
|
||||||
target_stats = stats.getOrAddUser(target.id)
|
target_stats = stats.getOrAddUser(target.id)
|
||||||
|
|
||||||
|
message_count = stats.getTotalMessageCount()
|
||||||
|
|
||||||
|
perc = round(int(target_stats[11]) * 100/message_count, 2)
|
||||||
|
|
||||||
embed = discord.Embed(colour=discord.Colour.blue())
|
embed = discord.Embed(colour=discord.Colour.blue())
|
||||||
embed.set_author(name=target.display_name, icon_url=target.avatar_url)
|
embed.set_author(name=target.display_name, icon_url=target.avatar_url)
|
||||||
embed.add_field(name="Aantal Berichten", value="{}".format(int(target_stats[11])))
|
embed.add_field(name="Aantal Berichten", value="{} ({}%)".format(int(target_stats[11]), perc))
|
||||||
embed.add_field(name="Level", value=str(xp.calculate_level(target_stats[12])))
|
embed.add_field(name="Level", value=str(xp.calculate_level(target_stats[12])))
|
||||||
embed.add_field(name="XP", value="{:,}".format(int(target_stats[12])))
|
embed.add_field(name="XP", value="{:,}".format(int(target_stats[12])))
|
||||||
embed.set_footer(text="*Sinds Didier 2.0 Launch")
|
embed.set_footer(text="*Sinds Didier 2.0 Launch")
|
||||||
|
|
|
@ -46,6 +46,15 @@ holidayAPIKey = "af4e1ebe-465d-4b93-a828-b95df18e6424"
|
||||||
|
|
||||||
prefixes = ["big d", "didier"]
|
prefixes = ["big d", "didier"]
|
||||||
|
|
||||||
|
faq_channels = {
|
||||||
|
727876753523081216: "ad2",
|
||||||
|
727876779481497600: "comnet",
|
||||||
|
727876797458284584: "funcprog",
|
||||||
|
727876819264733244: "statprob",
|
||||||
|
727876836587208714: "sysprog",
|
||||||
|
676713433567199232: "didier"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Live(Enum):
|
class Live(Enum):
|
||||||
CallOfCode = "626699611192688641"
|
CallOfCode = "626699611192688641"
|
||||||
|
|
|
@ -107,6 +107,12 @@ def gainXp(user, user_db):
|
||||||
update(user, "last_message", round(time.time()))
|
update(user, "last_message", round(time.time()))
|
||||||
|
|
||||||
|
|
||||||
|
def getTotalMessageCount():
|
||||||
|
r = getAllRows()
|
||||||
|
|
||||||
|
return sum(user[11] for user in r)
|
||||||
|
|
||||||
|
|
||||||
def getOrAddChannel(channelid: int):
|
def getOrAddChannel(channelid: int):
|
||||||
connection = utils.connect()
|
connection = utils.connect()
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
|
@ -83,10 +83,10 @@ def check(content, earlier=[]):
|
||||||
for letter in content[0]:
|
for letter in content[0]:
|
||||||
c = content[0].count(letter)
|
c = content[0].count(letter)
|
||||||
|
|
||||||
# If a letter was added twice, but there is only one, that's an issue
|
# If a letter was added three times, but there is only two, that's an issue
|
||||||
if c != 1 and letter not in doubles:
|
if c > 2 and letter not in doubles:
|
||||||
return False, ["Er zijn niet genoeg **{}**'s om dit woord te reacten.".format(letter)]
|
return False, ["Er zijn niet genoeg **{}**'s om dit woord te reacten.".format(letter)]
|
||||||
elif c > 1 and letter in doubles and len(doubles[letter]) < c:
|
elif c > 2 and letter in doubles and len(doubles[letter]) < c:
|
||||||
return False, ["Er zijn niet genoeg **{}**'s om dit woord te reacten.".format(letter)]
|
return False, ["Er zijn niet genoeg **{}**'s om dit woord te reacten.".format(letter)]
|
||||||
|
|
||||||
# Array of emoji's
|
# Array of emoji's
|
||||||
|
@ -96,14 +96,24 @@ def check(content, earlier=[]):
|
||||||
for letter in content[0]:
|
for letter in content[0]:
|
||||||
# Letters
|
# Letters
|
||||||
if letter.isalpha():
|
if letter.isalpha():
|
||||||
|
reg_ind = "regional_indicator_{}".format(letter)
|
||||||
|
zb = "zb_{}".format(letter.upper())
|
||||||
|
|
||||||
# Check if this letter has not been added yet
|
# Check if this letter has not been added yet
|
||||||
if "regional_indicator_{}".format(letter) in unidic and unidic["regional_indicator_{}".format(letter)] not in arr:
|
if reg_ind in unidic and unidic[reg_ind] not in arr:
|
||||||
arr.append(unidic["regional_indicator_{}".format(letter)])
|
arr.append(unidic[reg_ind])
|
||||||
|
|
||||||
# Remove this letter as an option from the list of doubles
|
# Remove this letter as an option from the list of doubles
|
||||||
if letter in doubles:
|
if letter in doubles:
|
||||||
doubles[letter] = doubles[letter][1:]
|
doubles[letter] = doubles[letter][1:]
|
||||||
|
|
||||||
|
# Check for Zandbak copies
|
||||||
|
elif zb in unidic and unidic[zb] not in arr:
|
||||||
|
arr.append(unidic[zb])
|
||||||
|
|
||||||
|
# Remove this letter as an option from the list of doubles
|
||||||
|
if letter in doubles:
|
||||||
|
doubles[letter] = doubles[letter][1:]
|
||||||
# Letter has been added before, but there's a double for it
|
# Letter has been added before, but there's a double for it
|
||||||
elif letter in doubles:
|
elif letter in doubles:
|
||||||
if len(doubles[letter]) == 0:
|
if len(doubles[letter]) == 0:
|
||||||
|
@ -163,15 +173,15 @@ def allowedCharacters():
|
||||||
|
|
||||||
def getDoubles():
|
def getDoubles():
|
||||||
doubles = {
|
doubles = {
|
||||||
"a": ["regional_indicator_a", "a", "four"],
|
"a": ["regional_indicator_a", "zb_A", "a", "four"],
|
||||||
"b": ["regional_indicator_b", "b"],
|
"b": ["regional_indicator_b", "zb_B", "b"],
|
||||||
"o": ["regional_indicator_o", "o2", "zero"],
|
"o": ["regional_indicator_o", "zb_O", "o2", "zero"],
|
||||||
"i": ["regional_indicator_i", "information_source", "one"],
|
"i": ["regional_indicator_i", "zb_I", "information_source", "one"],
|
||||||
"p": ["regional_indicator_p", "parking"],
|
"p": ["regional_indicator_p", "zb_P", "parking"],
|
||||||
"m": ["regional_indicator_m", "m"],
|
"m": ["regional_indicator_m", "zb_M", "m"],
|
||||||
"s": ["regional_indicator_s", "five"],
|
"s": ["regional_indicator_s", "zb_S", "five"],
|
||||||
"g": ["regional_indicator_g", "six"],
|
"g": ["regional_indicator_g", "zb_G", "six"],
|
||||||
"e": ["regional_indicator_e", "three"],
|
"e": ["regional_indicator_e", "zb_E", "three"],
|
||||||
"!": ["exclamation", "grey_exclamation"],
|
"!": ["exclamation", "grey_exclamation"],
|
||||||
"?": ["question", "grey_question"]
|
"?": ["question", "grey_question"]
|
||||||
}
|
}
|
||||||
|
@ -235,6 +245,32 @@ def getUnicodeDict():
|
||||||
"regional_indicator_x": "🇽",
|
"regional_indicator_x": "🇽",
|
||||||
"regional_indicator_y": "🇾",
|
"regional_indicator_y": "🇾",
|
||||||
"regional_indicator_z": "🇿",
|
"regional_indicator_z": "🇿",
|
||||||
|
"zb_A": "<:zb_A:792094798516453387>",
|
||||||
|
"zb_B": "<:zb_B:792094798986346507>",
|
||||||
|
"zb_C": "<:zb_C:792094799724412958>",
|
||||||
|
"zb_D": "<:zb_D:792094799984984124>",
|
||||||
|
"zb_E": "<:zb_E:792094800093380649>",
|
||||||
|
"zb_F": "<:zb_F:792094799657566278>",
|
||||||
|
"zb_G": "<:zb_G:792094800014606336>",
|
||||||
|
"zb_H": "<:zb_H:792094799745908736>",
|
||||||
|
"zb_I": "<:zb_I:792094799620079626>",
|
||||||
|
"zb_J": "<:zb_J:792094799800958976>",
|
||||||
|
"zb_K": "<:zb_K:792094800069263420>",
|
||||||
|
"zb_L": "<:zb_L:792094754036383755>",
|
||||||
|
"zb_M": "<:zb_M:792094704674013234>",
|
||||||
|
"zb_N": "<:zb_N:792094660281630751>",
|
||||||
|
"zb_O": "<:zb_O:792094628848467998>",
|
||||||
|
"zb_P": "<:zb_P:792094590793940992>",
|
||||||
|
"zb_Q": "<:zb_Q:792094558417584138>",
|
||||||
|
"zb_R": "<:zb_R:792094529951498260>",
|
||||||
|
"zb_S": "<:zb_S:792094506526572564>",
|
||||||
|
"zb_T": "<:zb_T:792094451530334228>",
|
||||||
|
"zb_U": "<:zb_U:792094420195082240>",
|
||||||
|
"zb_V": "<:zb_V:792094388716437544>",
|
||||||
|
"zb_W": "<:zb_W:792094342285754378>",
|
||||||
|
"zb_X": "<:zb_X:792094308412293190>",
|
||||||
|
"zb_Y": "<:zb_Y:792094270445322270>",
|
||||||
|
"zb_Z": "<:zb_Z:792094240212779028>",
|
||||||
"a": "🅰️",
|
"a": "🅰️",
|
||||||
"b": "🅱️",
|
"b": "🅱️",
|
||||||
"o2": "🅾️",
|
"o2": "🅾️",
|
||||||
|
@ -270,6 +306,7 @@ def getAllVariants(char: str):
|
||||||
reg_ind = "regional_indicator_{}".format(char)
|
reg_ind = "regional_indicator_{}".format(char)
|
||||||
if reg_ind in getUnicodeDict():
|
if reg_ind in getUnicodeDict():
|
||||||
variants.append(reg_ind)
|
variants.append(reg_ind)
|
||||||
|
variants.append("zb_{}".format(char.upper()))
|
||||||
|
|
||||||
# Number
|
# Number
|
||||||
elif char in getNumbers():
|
elif char in getNumbers():
|
||||||
|
@ -292,6 +329,11 @@ def getAllVariants(char: str):
|
||||||
print(variants)
|
print(variants)
|
||||||
for var in variants:
|
for var in variants:
|
||||||
rep = ":" + var + ":"
|
rep = ":" + var + ":"
|
||||||
|
|
||||||
|
# Zandbak copies are formatted differently
|
||||||
|
if var.startswith("zb_"):
|
||||||
|
rep = getUnicodeDict()[var]
|
||||||
|
|
||||||
if rep not in uniques:
|
if rep not in uniques:
|
||||||
uniques.append(rep)
|
uniques.append(rep)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import dateutil.relativedelta
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
|
|
||||||
def epochToDate(epochTimeStamp, strFormat="%m/%d/%Y om %H:%M:%S"):
|
def epochToDate(epochTimeStamp, strFormat="%d/%m/%Y om %H:%M:%S"):
|
||||||
now = dateTimeNow()
|
now = dateTimeNow()
|
||||||
updateTime = datetime.datetime.fromtimestamp(int(epochTimeStamp), pytz.timezone("Europe/Brussels"))
|
updateTime = datetime.datetime.fromtimestamp(int(epochTimeStamp), pytz.timezone("Europe/Brussels"))
|
||||||
diff = now - updateTime
|
diff = now - updateTime
|
||||||
|
|
Loading…
Reference in New Issue