Skip to content

Commit

Permalink
Merge pull request #93 from LewisProjects/development
Browse files Browse the repository at this point in the history
Restrict Discord invites in tag
  • Loading branch information
LevaniVashadze authored Dec 5, 2023
2 parents 9169667 + 1478744 commit a6ac64e
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions cogs/Tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ async def create(
return await errorEmb(inter, f"tag **{name}** already exists")

if len(content) >= 1900:
return await errorEmb(
inter, "The tag's content must be under 1900 chars"
)
return await errorEmb(inter, "The tag's content must be under 1900 chars")
elif re.match(
"(https|http)://(dsc\.gg|discord\.gg|discord\.io|dsc\.lol)/?[\S]+/?",
content,
):
return await errorEmb(inter, "You can't make a tag with an invite")
elif not await self.valid_name(name):
return (
await QuickEmb(
Expand Down Expand Up @@ -184,9 +187,7 @@ async def transfer(
name = name.casefold()
await self.tags.exists(name, TagNotFound, should=True)
if new_owner.bot:
return await errorEmb(
inter, "You can't transfer a tag to a bot!"
)
return await errorEmb(inter, "You can't transfer a tag to a bot!")
elif (
inter.author.id != (await self.tags.get(name)).owner
) and not manage_messages_perms(inter):
Expand Down Expand Up @@ -219,9 +220,7 @@ async def claim(self, inter: ApplicationCommandInteraction, name):
):
await self.tags.transfer(name, inter.author.id)
return (
await QuickEmb(
inter, f"I have transferred **{name}** to you"
)
await QuickEmb(inter, f"I have transferred **{name}** to you")
.success()
.send()
)
Expand Down Expand Up @@ -280,18 +279,14 @@ async def info(self, inter: ApplicationCommandInteraction, name):
emb.add_field(name="Owner", value=owner.mention)
aliases = await self.tags.get_aliases(name)
if aliases:
emb.add_field(
name="Aliases", value=", ".join(tag for tag in aliases)
)
emb.add_field(name="Aliases", value=", ".join(tag for tag in aliases))
emb.add_field(name="Created At", value=f"<t:{tag.created_at}:R>")
emb.add_field(name="Times Called", value=abs(tag.views))
await inter.send(embed=emb)
except TagNotFound:
return await errorEmb(inter, f"tag **{name}** does not exist")

@tag.sub_command(
name="leaderboard", description="Lists shows top tags (by views)"
)
@tag.sub_command(name="leaderboard", description="Lists shows top tags (by views)")
@commands.guild_only()
@commands.cooldown(1, 30, commands.BucketType.guild)
async def leaderboard(self, inter: ApplicationCommandInteraction):
Expand Down Expand Up @@ -421,21 +416,15 @@ async def help(self, inter):
for cmd, desc in tag_help["public"].items():
general_cmds += f"**/{cmd}** *~~* {desc}\n\t"
for cmd, desc in tag_help["owner_only"].items():
owner_cmds += (
f"**/{cmd}** *~~* {desc} (only usable by the tag's owner)\n"
)
owner_cmds += f"**/{cmd}** *~~* {desc} (only usable by the tag's owner)\n"

emb.add_field(
name=f"General commands", value=general_cmds + "\n\n", inline=False
)
emb.add_field(
name=f"Tag owner only commands", value=owner_cmds, inline=False
)
emb.add_field(name=f"Tag owner only commands", value=owner_cmds, inline=False)
await inter.send(embed=emb)

@tag.sub_command_group(
name="alias", description="Aliases a tag", hidden=True
)
@tag.sub_command_group(name="alias", description="Aliases a tag", hidden=True)
@commands.guild_only()
async def alias(self, inter):
pass
Expand Down Expand Up @@ -473,13 +462,9 @@ async def add_alias(self, inter, name, alias):
except AliasAlreadyExists:
return await errorEmb(inter, f"alias **{alias}** already exists")
except AliasLimitReached:
return await errorEmb(
inter, "You can only have 10 aliases per tag"
)
return await errorEmb(inter, "You can only have 10 aliases per tag")

@alias.sub_command(
name="remove", description="Removes an alias from a tag"
)
@alias.sub_command(name="remove", description="Removes an alias from a tag")
@commands.guild_only()
async def remove_alias(self, inter, name, alias):
try:
Expand Down

0 comments on commit a6ac64e

Please sign in to comment.