Mostly fix CTC2
This commit is contained in:
parent
ff71e93720
commit
f0502d65db
1 changed files with 14 additions and 6 deletions
|
@ -7,7 +7,11 @@ from dis_snek import InteractionContext, Scale, Snake
|
||||||
from dis_snek.ext.paginators import Paginator
|
from dis_snek.ext.paginators import Paginator
|
||||||
from dis_snek.models.discord.embed import EmbedField
|
from dis_snek.models.discord.embed import EmbedField
|
||||||
from dis_snek.models.discord.user import Member, User
|
from dis_snek.models.discord.user import Member, User
|
||||||
from dis_snek.models.snek.application_commands import SlashCommand
|
from dis_snek.models.snek.application_commands import (
|
||||||
|
OptionTypes,
|
||||||
|
SlashCommand,
|
||||||
|
slash_option,
|
||||||
|
)
|
||||||
from dis_snek.models.snek.command import cooldown
|
from dis_snek.models.snek.command import cooldown
|
||||||
from dis_snek.models.snek.cooldowns import Buckets
|
from dis_snek.models.snek.cooldowns import Buckets
|
||||||
from jarvis_core.db import q
|
from jarvis_core.db import q
|
||||||
|
@ -15,7 +19,7 @@ from jarvis_core.db.models import Guess
|
||||||
|
|
||||||
from jarvis.utils import build_embed
|
from jarvis.utils import build_embed
|
||||||
|
|
||||||
guild_ids = [578757004059738142, 520021794380447745, 862402786116763668]
|
guild_ids = [862402786116763668] # [578757004059738142, 520021794380447745, 862402786116763668]
|
||||||
|
|
||||||
valid = re.compile(r"[\w\s\-\\/.!@#$%^*()+=<>,\u0080-\U000E0FFF]*")
|
valid = re.compile(r"[\w\s\-\\/.!@#$%^*()+=<>,\u0080-\U000E0FFF]*")
|
||||||
invites = re.compile(
|
invites = re.compile(
|
||||||
|
@ -36,7 +40,7 @@ class CTCCog(Scale):
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self._session.close()
|
self._session.close()
|
||||||
|
|
||||||
ctc2 = SlashCommand(name="ctc2", description="CTC2 related commands", scopres=guild_ids)
|
ctc2 = SlashCommand(name="ctc2", description="CTC2 related commands", scopes=guild_ids)
|
||||||
|
|
||||||
@ctc2.subcommand(sub_cmd_name="about")
|
@ctc2.subcommand(sub_cmd_name="about")
|
||||||
@cooldown(bucket=Buckets.USER, rate=1, interval=30)
|
@cooldown(bucket=Buckets.USER, rate=1, interval=30)
|
||||||
|
@ -47,6 +51,9 @@ class CTCCog(Scale):
|
||||||
sub_cmd_name="pw",
|
sub_cmd_name="pw",
|
||||||
sub_cmd_description="Guess a password for https://completethecodetwo.cards",
|
sub_cmd_description="Guess a password for https://completethecodetwo.cards",
|
||||||
)
|
)
|
||||||
|
@slash_option(
|
||||||
|
name="guess", description="Guess a password", opt_type=OptionTypes.STRING, required=True
|
||||||
|
)
|
||||||
@cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
@cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
||||||
async def _pw(self, ctx: InteractionContext, guess: str) -> None:
|
async def _pw(self, ctx: InteractionContext, guess: str) -> None:
|
||||||
if len(guess) > 800:
|
if len(guess) > 800:
|
||||||
|
@ -85,7 +92,7 @@ class CTCCog(Scale):
|
||||||
correct = True
|
correct = True
|
||||||
else:
|
else:
|
||||||
await ctx.send("Nope.", ephemeral=True)
|
await ctx.send("Nope.", ephemeral=True)
|
||||||
_ = Guess(guess=guess, user=ctx.author.id, correct=correct).save()
|
await Guess(guess=guess, user=ctx.author.id, correct=correct).commit()
|
||||||
|
|
||||||
@ctc2.subcommand(
|
@ctc2.subcommand(
|
||||||
sub_cmd_name="guesses",
|
sub_cmd_name="guesses",
|
||||||
|
@ -93,9 +100,10 @@ class CTCCog(Scale):
|
||||||
)
|
)
|
||||||
@cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
@cooldown(bucket=Buckets.USER, rate=1, interval=2)
|
||||||
async def _guesses(self, ctx: InteractionContext) -> None:
|
async def _guesses(self, ctx: InteractionContext) -> None:
|
||||||
guesses = Guess.objects().order_by("-correct", "-id")
|
await ctx.defer()
|
||||||
|
guesses = Guess.find().sort("correct", -1).sort("id", -1)
|
||||||
fields = []
|
fields = []
|
||||||
for guess in guesses:
|
async for guess in guesses:
|
||||||
user = await ctx.guild.get_member(guess["user"])
|
user = await ctx.guild.get_member(guess["user"])
|
||||||
if not user:
|
if not user:
|
||||||
user = await self.bot.fetch_user(guess["user"])
|
user = await self.bot.fetch_user(guess["user"])
|
||||||
|
|
Loading…
Add table
Reference in a new issue