69 lines
No EOL
2.6 KiB
Python
69 lines
No EOL
2.6 KiB
Python
import nextcord
|
|
from nextcord.ext import commands, application_checks
|
|
from nextcord import TextInputStyle
|
|
import traceback
|
|
import random
|
|
import aiosqlite as sqlite3
|
|
import aiohttp
|
|
from urllib.parse import urlparse
|
|
import os
|
|
import sys
|
|
|
|
errormsg = ["How could you do this to me!", "I tried my best...", "Maybe this will be fixed next patch", "There's always next time", "Simply processed too hard", "Perhaps this will be fixed", "You found an easter egg! Wait no it's just an error..."]
|
|
|
|
|
|
class misc(commands.Cog):
|
|
|
|
def __init__(self, bot: commands.Bot):
|
|
self.bot = bot
|
|
|
|
@commands.Cog.listener('on_application_command_error')
|
|
async def errorhandler(self, interaction: nextcord.Interaction, error: nextcord.DiscordException):
|
|
error = traceback.format_exception(type(error), error, error.__traceback__)
|
|
random.shuffle(errormsg)
|
|
strerror = "".join(error)
|
|
print(strerror, file=sys.stderr)
|
|
message = f"{errormsg[0]}\n```py\n{strerror[-1800:]}\n```\n Contact <@{self.bot.owner_id}> if the error persists"
|
|
try:
|
|
await interaction.response.send_message(message, ephemeral=True)
|
|
except:
|
|
await interaction.followup.send(message, ephemeral=True)
|
|
|
|
@nextcord.slash_command(
|
|
name="testcommand",
|
|
description="Testing user installable",
|
|
integration_types=[
|
|
nextcord.IntegrationType.user_install,
|
|
],
|
|
contexts=[
|
|
nextcord.InteractionContextType.guild,
|
|
nextcord.InteractionContextType.bot_dm,
|
|
nextcord.InteractionContextType.private_channel,
|
|
],
|
|
force_global=True,
|
|
)
|
|
async def testcmd(self, interaction: nextcord.Interaction):
|
|
await interaction.response.send_message("Hey there this is a user installable command!")
|
|
|
|
@nextcord.message_command(
|
|
name="Pin Thread Message",
|
|
integration_types=[
|
|
nextcord.IntegrationType.guild_install,
|
|
],
|
|
contexts=[
|
|
nextcord.InteractionContextType.guild,
|
|
nextcord.InteractionContextType.private_channel,
|
|
],
|
|
guild_ids=[732793772697583623],
|
|
)
|
|
async def pinthreadmessage(self, interaction: nextcord.Interaction, message: nextcord.Message):
|
|
if message.channel.owner_id == interaction.user.id:
|
|
await message.pin()
|
|
await interaction.response.send_message("Pinned", ephemeral="True")
|
|
else:
|
|
await interaction.response.send_message("You don't have permission in this context", ephemeral="True")
|
|
|
|
|
|
|
|
def setup(bot: commands.Bot):
|
|
bot.add_cog(misc(bot)) |