Merge branch 'new-commands' into 'main'

New commands

Closes #62, #63, and #64

See merge request stark-industries/j.a.r.v.i.s.!17
This commit is contained in:
Zeva Rose 2021-07-22 15:08:45 +00:00
commit 3b2653962c
9 changed files with 80 additions and 1 deletions

View file

@ -36,7 +36,7 @@ jarvis = commands.Bot(
) )
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
jarvis_self = Process() jarvis_self = Process()
__version__ = "1.1.1" __version__ = "1.2.0"
db = DBManager(get_config().mongo).mongo db = DBManager(get_config().mongo).mongo

View file

@ -22,6 +22,7 @@ class CTCCog(commands.Cog):
description="CTC2 related commands", description="CTC2 related commands",
guild_ids=guild_ids, guild_ids=guild_ids,
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _about(self, ctx): async def _about(self, ctx):
await ctx.send("See https://completethecode.com for more information") await ctx.send("See https://completethecode.com for more information")
@ -31,6 +32,7 @@ class CTCCog(commands.Cog):
description="Guess a password for https://completethecodetwo.cards", description="Guess a password for https://completethecodetwo.cards",
guild_ids=guild_ids, guild_ids=guild_ids,
) )
@commands.cooldown(1, 2, commands.BucketType.uer)
async def _pw(self, ctx, guess: str): async def _pw(self, ctx, guess: str):
guessed = self.db.ctc2.guesses.find_one({"guess": guess}) guessed = self.db.ctc2.guesses.find_one({"guess": guess})
if guessed: if guessed:

View file

@ -34,6 +34,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="See what skins are available", description="See what skins are available",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _skin(self, ctx): async def _skin(self, ctx):
await ctx.send(self.base_url + "shop/skins") await ctx.send(self.base_url + "shop/skins")
@ -43,6 +44,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="Get some robot camo. Make Tony Stark proud", description="Get some robot camo. Make Tony Stark proud",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _camo(self, ctx): async def _camo(self, ctx):
await ctx.send(self.base_url + "shop/special-edition/robot-camo") await ctx.send(self.base_url + "shop/special-edition/robot-camo")
@ -52,6 +54,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="See devices with Grip support", description="See devices with Grip support",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _grip(self, ctx): async def _grip(self, ctx):
await ctx.send(self.base_url + "shop/grip/#grip-devices") await ctx.send(self.base_url + "shop/grip/#grip-devices")
@ -61,6 +64,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="Contact support", description="Contact support",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _contact(self, ctx): async def _contact(self, ctx):
await ctx.send( await ctx.send(
"Contact dbrand support here: " + self.base_url + "contact" "Contact dbrand support here: " + self.base_url + "contact"
@ -72,6 +76,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="Contact support", description="Contact support",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _support(self, ctx): async def _support(self, ctx):
await ctx.send( await ctx.send(
"Contact dbrand support here: " + self.base_url + "contact" "Contact dbrand support here: " + self.base_url + "contact"
@ -83,6 +88,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="Get your order status", description="Get your order status",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _orderstat(self, ctx): async def _orderstat(self, ctx):
await ctx.send(self.base_url + "order-status") await ctx.send(self.base_url + "order-status")
@ -92,6 +98,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="Get your order status", description="Get your order status",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _orders(self, ctx): async def _orders(self, ctx):
await ctx.send(self.base_url + "order-status") await ctx.send(self.base_url + "order-status")
@ -101,6 +108,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="dbrand status", description="dbrand status",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _status(self, ctx): async def _status(self, ctx):
await ctx.send(self.base_url + "status") await ctx.send(self.base_url + "status")
@ -110,6 +118,7 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="Give us your money!", description="Give us your money!",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _buy(self, ctx): async def _buy(self, ctx):
await ctx.send("Give us your money! " + self.base_url + "shop") await ctx.send("Give us your money! " + self.base_url + "shop")
@ -119,11 +128,24 @@ class DbrandCog(commands.Cog):
guild_ids=guild_ids, guild_ids=guild_ids,
description="(not) extortion", description="(not) extortion",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _extort(self, ctx): async def _extort(self, ctx):
await ctx.send( await ctx.send(
"Be (not) extorted here: " + self.base_url + "not-extortion" "Be (not) extorted here: " + self.base_url + "not-extortion"
) )
@cog_ext.cog_subcommand(
base="db",
name="wallpapers",
description="Robot Camo Wallpapers",
guild_ids=guild_ids,
)
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _wallpapers(self, ctx):
await ctx.send(
"Get robot camo wallpapers here: https://db.io/wallpapers"
)
@cog_ext.cog_subcommand( @cog_ext.cog_subcommand(
base="db", base="db",
name="ship", name="ship",
@ -141,6 +163,7 @@ class DbrandCog(commands.Cog):
) )
], ],
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _shipping(self, ctx, *, search: str): async def _shipping(self, ctx, *, search: str):
await ctx.defer() await ctx.defer()
if not re.match(r"^[A-Z- ]+$", search, re.IGNORECASE): if not re.match(r"^[A-Z- ]+$", search, re.IGNORECASE):

View file

@ -99,6 +99,7 @@ class DevCog(commands.Cog):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="hash") @commands.command(name="hash")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _hash_pref(self, ctx, method: str, *, data: str = None): async def _hash_pref(self, ctx, method: str, *, data: str = None):
await self._hash(ctx, method, data=data) await self._hash(ctx, method, data=data)
@ -106,6 +107,7 @@ class DevCog(commands.Cog):
name="hash", name="hash",
description="Hash some data", description="Hash some data",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _hash_slash(self, ctx, method: str, *, data: str = None): async def _hash_slash(self, ctx, method: str, *, data: str = None):
await self._hash(ctx, method, data=data) await self._hash(ctx, method, data=data)
@ -135,6 +137,7 @@ class DevCog(commands.Cog):
await ctx.send(f"UUID{version}: `{to_send}`") await ctx.send(f"UUID{version}: `{to_send}`")
@commands.command(name="uuid") @commands.command(name="uuid")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _uuid_pref(self, ctx, version: str = None, data: str = None): async def _uuid_pref(self, ctx, version: str = None, data: str = None):
await self._uuid(ctx, version, data) await self._uuid(ctx, version, data)
@ -142,6 +145,7 @@ class DevCog(commands.Cog):
name="uuid", name="uuid",
description="Generate a UUID", description="Generate a UUID",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _uuid_slash(self, ctx, version: str = None, data: str = None): async def _uuid_slash(self, ctx, version: str = None, data: str = None):
await self._uuid(ctx, version, data) await self._uuid(ctx, version, data)
@ -150,6 +154,7 @@ class DevCog(commands.Cog):
await ctx.send(f"ObjectId: `{str(ObjectId())}`") await ctx.send(f"ObjectId: `{str(ObjectId())}`")
@commands.command(name="objectid") @commands.command(name="objectid")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _objectid_pref(self, ctx): async def _objectid_pref(self, ctx):
await self._objectid(ctx) await self._objectid(ctx)
@ -157,6 +162,7 @@ class DevCog(commands.Cog):
name="objectid", name="objectid",
description="Generate an ObjectID", description="Generate an ObjectID",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _objectid_slash(self, ctx): async def _objectid_slash(self, ctx):
await self._objectid(ctx) await self._objectid(ctx)
@ -165,6 +171,7 @@ class DevCog(commands.Cog):
await ctx.send(f"ULID: `{ulid.new().str}`") await ctx.send(f"ULID: `{ulid.new().str}`")
@commands.command(name="ulid") @commands.command(name="ulid")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _ulid_pref(self, ctx): async def _ulid_pref(self, ctx):
await self._ulid(ctx) await self._ulid(ctx)
@ -172,6 +179,7 @@ class DevCog(commands.Cog):
name="ulid", name="ulid",
description="Generate a ULID", description="Generate a ULID",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _ulid_slash(self, ctx): async def _ulid_slash(self, ctx):
await self._ulid(ctx) await self._ulid(ctx)
@ -184,6 +192,7 @@ class DevCog(commands.Cog):
await ctx.send("Invalid UUID") await ctx.send("Invalid UUID")
@commands.command(name="uuid2ulid") @commands.command(name="uuid2ulid")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _uuid2ulid_pref(self, ctx, u: str): async def _uuid2ulid_pref(self, ctx, u: str):
await self._uuid2ulid(ctx, u) await self._uuid2ulid(ctx, u)
@ -191,6 +200,7 @@ class DevCog(commands.Cog):
name="uuid2ulid", name="uuid2ulid",
description="Convert a UUID to a ULID", description="Convert a UUID to a ULID",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _uuid2ulid_slash(self, ctx, u: str): async def _uuid2ulid_slash(self, ctx, u: str):
await self._uuid2ulid(ctx, u) await self._uuid2ulid(ctx, u)
@ -203,6 +213,7 @@ class DevCog(commands.Cog):
await ctx.send("Invalid ULID.") await ctx.send("Invalid ULID.")
@commands.command(name="ulid2uuid") @commands.command(name="ulid2uuid")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _ulid2uuid_pref(self, ctx, u): async def _ulid2uuid_pref(self, ctx, u):
await self._ulid2uuid(ctx, u) await self._ulid2uuid(ctx, u)
@ -210,6 +221,7 @@ class DevCog(commands.Cog):
name="ulid2uuid", name="ulid2uuid",
description="Convert a ULID to a UUID", description="Convert a ULID to a UUID",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _ulid2uuid_slash(self, ctx, u): async def _ulid2uuid_slash(self, ctx, u):
await self._ulid2uuid(ctx, u) await self._ulid2uuid(ctx, u)
@ -229,6 +241,7 @@ class DevCog(commands.Cog):
await ctx.send(f"`{method(data.encode('UTF-8')).decode('UTF-8')}`") await ctx.send(f"`{method(data.encode('UTF-8')).decode('UTF-8')}`")
@commands.command(name="encode") @commands.command(name="encode")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _encode_pref(self, ctx, method: str, *, data: str): async def _encode_pref(self, ctx, method: str, *, data: str):
await self._encode(ctx, method, data) await self._encode(ctx, method, data)
@ -236,6 +249,7 @@ class DevCog(commands.Cog):
name="encode", name="encode",
description="Encode using the base64 module", description="Encode using the base64 module",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _encode_slash(self, ctx, method: str, *, data: str): async def _encode_slash(self, ctx, method: str, *, data: str):
await self._encode(ctx, method, data) await self._encode(ctx, method, data)
@ -253,6 +267,7 @@ class DevCog(commands.Cog):
await ctx.send(f"`{method(data.encode('UTF-8')).decode('UTF-8')}`") await ctx.send(f"`{method(data.encode('UTF-8')).decode('UTF-8')}`")
@commands.command(name="decode") @commands.command(name="decode")
@commands.cooldown(1, 2, commands.BucketType.user)
async def _decode_pref(self, ctx, method: str, *, data: str): async def _decode_pref(self, ctx, method: str, *, data: str):
await self._decode(ctx, method, data) await self._decode(ctx, method, data)
@ -260,6 +275,7 @@ class DevCog(commands.Cog):
name="decode", name="decode",
description="Decode using the base64 module", description="Decode using the base64 module",
) )
@commands.cooldown(1, 2, commands.BucketType.user)
async def _decode_slash(self, ctx, method: str, *, data: str): async def _decode_slash(self, ctx, method: str, *, data: str):
await self._decode(ctx, method, data) await self._decode(ctx, method, data)
@ -270,6 +286,7 @@ class DevCog(commands.Cog):
await ctx.send(f"```\n{output}\n```") await ctx.send(f"```\n{output}\n```")
@commands.command(name="cloc", help="Get J.A.R.V.I.S. lines of code") @commands.command(name="cloc", help="Get J.A.R.V.I.S. lines of code")
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _cloc_pref(self, ctx): async def _cloc_pref(self, ctx):
await self._cloc(ctx) await self._cloc(ctx)
@ -277,6 +294,7 @@ class DevCog(commands.Cog):
name="cloc", name="cloc",
description="Get J.A.R.V.I.S. lines of code", description="Get J.A.R.V.I.S. lines of code",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _cloc_slash(self, ctx): async def _cloc_slash(self, ctx):
await ctx.defer() await ctx.defer()
await self._cloc(ctx) await self._cloc(ctx)

View file

@ -104,6 +104,7 @@ class ImageCog(commands.Cog):
) )
@commands.command(name="resize", help="Resize an image") @commands.command(name="resize", help="Resize an image")
@commands.cooldown(1, 60, commands.BucketType.user)
async def _resize_pref(self, ctx, target: str, url: str = None): async def _resize_pref(self, ctx, target: str, url: str = None):
await self._resize(ctx, target, url) await self._resize(ctx, target, url)

View file

@ -127,6 +127,7 @@ class JokeCog(commands.Cog):
name="joke", name="joke",
description="Hear a joke", description="Hear a joke",
) )
@commands.cooldown(1, 10, commands.BucketType.channel)
async def _joke_slash(self, ctx, id: str = None): async def _joke_slash(self, ctx, id: str = None):
await self._joke(ctx, id) await self._joke(ctx, id)

View file

@ -148,6 +148,9 @@ class StarboardCog(commands.Cog):
) )
return return
if message.startswith("https://"):
message = message.split("/")[-1]
message = await channel.fetch_message(int(message)) message = await channel.fetch_message(int(message))
exists = Star.get( exists = Star.get(

View file

@ -1,5 +1,6 @@
import re import re
from discord import User
from discord.ext import commands from discord.ext import commands
from discord_slash import SlashContext, cog_ext from discord_slash import SlashContext, cog_ext
from discord_slash.utils.manage_commands import create_option from discord_slash.utils.manage_commands import create_option
@ -26,6 +27,7 @@ class UtilCog(commands.Cog):
name="status", name="status",
description="Retrieve J.A.R.V.I.S. status", description="Retrieve J.A.R.V.I.S. status",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _status(self, ctx): async def _status(self, ctx):
title = "J.A.R.V.I.S. Status" title = "J.A.R.V.I.S. Status"
desc = "All systems online" desc = "All systems online"
@ -51,6 +53,7 @@ class UtilCog(commands.Cog):
name="logo", name="logo",
description="Get the current logo", description="Get the current logo",
) )
@commands.cooldown(1, 30, commands.BucketType.channel)
async def _logo(self, ctx): async def _logo(self, ctx):
lo = logo.get_logo(self.config.logo) lo = logo.get_logo(self.config.logo)
await ctx.send(f"```\n{lo}\n```") await ctx.send(f"```\n{lo}\n```")
@ -88,6 +91,33 @@ class UtilCog(commands.Cog):
else: else:
await ctx.send(to_send) await ctx.send(to_send)
@cog_ext.cog_slash(
name="avatar",
description="Get a user avatar",
options=[
create_option(
name="user",
description="User to view avatar of",
option_type=6,
required=False,
)
],
)
@commands.cooldown(1, 5, commands.BucketType.user)
async def _avatar(self, ctx, user: User = None):
if not user:
user = ctx.author
avatar = user.avatar_url
embed = build_embed(
title="Avatar", description="", fields=[], color="#00FFEE"
)
embed.set_image(url=avatar)
embed.set_author(
name=f"{user.name}#{user.discriminator}", icon_url=avatar
)
await ctx.send(embed=embed)
def setup(bot): def setup(bot):
bot.add_cog(UtilCog(bot)) bot.add_cog(UtilCog(bot))

View file

@ -34,6 +34,7 @@ class VerifyCog(commands.Cog):
name="verify", name="verify",
description="Verify that you've read the rules", description="Verify that you've read the rules",
) )
@commands.cooldown(1, 15, commands.BucketType.user)
async def _verify(self, ctx: SlashContext): async def _verify(self, ctx: SlashContext):
await ctx.defer() await ctx.defer()
role = Setting.get(guild=ctx.guild.id, setting="verified") role = Setting.get(guild=ctx.guild.id, setting="verified")