2025-09-15 09:00:02 -04:00
|
|
|
import os
|
2025-09-14 18:54:56 -04:00
|
|
|
import discord
|
2025-09-22 10:22:06 -04:00
|
|
|
from discord import app_commands
|
2025-09-14 18:54:56 -04:00
|
|
|
from discord.ext import commands
|
|
|
|
|
from discord.ext.commands import Context
|
2025-10-14 17:24:41 -04:00
|
|
|
from utils.checks import is_owner_or_friend
|
2025-09-14 18:54:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Invite(commands.Cog, name="invite"):
|
|
|
|
|
def __init__(self, bot) -> None:
|
|
|
|
|
self.bot = bot
|
|
|
|
|
|
2025-11-02 23:32:52 -05:00
|
|
|
async def send_embed(
|
|
|
|
|
self, context: Context, embed: discord.Embed, *, ephemeral: bool = False
|
|
|
|
|
) -> None:
|
2025-09-16 07:43:56 -04:00
|
|
|
interaction = getattr(context, "interaction", None)
|
|
|
|
|
if interaction is not None:
|
|
|
|
|
if interaction.response.is_done():
|
|
|
|
|
await interaction.followup.send(embed=embed, ephemeral=ephemeral)
|
|
|
|
|
else:
|
2025-11-02 23:32:52 -05:00
|
|
|
await interaction.response.send_message(
|
|
|
|
|
embed=embed, ephemeral=ephemeral
|
|
|
|
|
)
|
2025-09-16 07:43:56 -04:00
|
|
|
else:
|
|
|
|
|
await context.send(embed=embed)
|
|
|
|
|
|
2025-09-14 18:54:56 -04:00
|
|
|
@commands.hybrid_command(
|
|
|
|
|
name="invite",
|
|
|
|
|
description="Get the invite link of the bot to be able to invite it.",
|
|
|
|
|
)
|
2025-09-22 10:22:06 -04:00
|
|
|
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
|
|
|
|
|
@app_commands.allowed_installs(guilds=True, users=True)
|
2025-10-14 17:24:41 -04:00
|
|
|
@is_owner_or_friend()
|
2025-09-14 18:54:56 -04:00
|
|
|
async def invite(self, context: Context) -> None:
|
|
|
|
|
"""
|
|
|
|
|
Get the invite link of the bot to be able to invite it.
|
|
|
|
|
|
|
|
|
|
:param context: The hybrid command context.
|
|
|
|
|
"""
|
2025-09-15 09:00:02 -04:00
|
|
|
client = self.bot.user
|
|
|
|
|
if client is None:
|
|
|
|
|
await context.send("Bot is not ready. Try again shortly.")
|
|
|
|
|
return
|
2025-09-22 08:42:38 -04:00
|
|
|
invite_link = os.getenv("INVITE_LINK")
|
2025-11-02 23:32:52 -05:00
|
|
|
embed = discord.Embed(
|
|
|
|
|
title="Install",
|
|
|
|
|
description=f"Install me by clicking [here]({invite_link}).",
|
|
|
|
|
color=0x7289DA,
|
|
|
|
|
)
|
|
|
|
|
embed.set_author(
|
|
|
|
|
name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp"
|
|
|
|
|
)
|
|
|
|
|
|
2025-10-03 18:30:27 -04:00
|
|
|
await self.send_embed(context, embed, ephemeral=False)
|
2025-09-16 07:43:56 -04:00
|
|
|
|
|
|
|
|
async def cog_command_error(self, context: Context, error) -> None:
|
2025-10-14 17:24:41 -04:00
|
|
|
if isinstance(error, (commands.NotOwner, commands.CheckFailure)):
|
2025-09-16 07:43:56 -04:00
|
|
|
embed = discord.Embed(
|
|
|
|
|
title="Permission Denied",
|
|
|
|
|
description="You are not the owner of this bot.",
|
2025-11-02 23:32:52 -05:00
|
|
|
color=0xE02B2B,
|
|
|
|
|
)
|
|
|
|
|
embed.set_author(
|
|
|
|
|
name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp"
|
2025-09-16 07:43:56 -04:00
|
|
|
)
|
|
|
|
|
await self.send_embed(context, embed, ephemeral=True)
|
|
|
|
|
else:
|
|
|
|
|
raise error
|
2025-09-14 18:54:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async def setup(bot) -> None:
|
|
|
|
|
await bot.add_cog(Invite(bot))
|