Merge branch 'main' of https://git.insertapp.net/insert/insert2-cogs
This commit is contained in:
commit
7f2b81e6a8
2 changed files with 72 additions and 1 deletions
71
starboard.py
Normal file
71
starboard.py
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
import nextcord
|
||||||
|
from nextcord.ext import commands
|
||||||
|
from nextcord import TextInputStyle
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from random import randint
|
||||||
|
import aiosqlite as sqlite3
|
||||||
|
import json
|
||||||
|
import traceback
|
||||||
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
|
import base64
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
import os
|
||||||
|
|
||||||
|
class starboard(commands.Cog):
|
||||||
|
def __init__(self, bot: commands.Bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener('on_raw_reaction_add')
|
||||||
|
async def on_raw_reaction_add(self,payload):
|
||||||
|
print("recieved emoji payload", file=sys.stderr)
|
||||||
|
print(payload.emoji.name, file=sys.stderr)
|
||||||
|
chann = self.bot.get_channel(payload.channel_id)
|
||||||
|
message = await chann.fetch_message(payload.message_id)
|
||||||
|
res = await self.bot.cur.execute(f"SELECT emoji, starchannel, minimumneeded, selfstar FROM starsettings WHERE serverid = {message.guild.id}")
|
||||||
|
try:
|
||||||
|
emoji, starchannel, minimumneeded, selfstar = await res.fetchone()
|
||||||
|
except TypeError:
|
||||||
|
return
|
||||||
|
if payload.emoji.name == emoji:
|
||||||
|
print("Recieved star payload", file=sys.stderr)
|
||||||
|
for r in message.reactions:
|
||||||
|
if r.emoji == emoji:
|
||||||
|
if r.count == minimumneeded:
|
||||||
|
await chann.send(f"{r.count} {payload.emoji.name}")
|
||||||
|
await message.forward(self.bot.get_channel(starchannel))
|
||||||
|
return
|
||||||
|
|
||||||
|
@nextcord.slash_command(
|
||||||
|
name="starboardr",
|
||||||
|
description="For all your starring needs",
|
||||||
|
default_member_permissions=nextcord.Permissions(manage_messages=True),
|
||||||
|
force_global=True,
|
||||||
|
)
|
||||||
|
async def starboardr(self, interaction: nextcord.Interaction):
|
||||||
|
return
|
||||||
|
|
||||||
|
@starboardr.subcommand(
|
||||||
|
name="create",
|
||||||
|
description="Create a starboard, escape the emoji",
|
||||||
|
)
|
||||||
|
async def createstarboard(self, interaction: nextcord.Interaction, reaction: str, channel: nextcord.abc.GuildChannel, minimumneeded: int, selfstar: str = nextcord.SlashOption(choices=["Yes", "No"])):
|
||||||
|
selfstar = False
|
||||||
|
if selfstar == "Yes":
|
||||||
|
selfstar = True
|
||||||
|
await self.bot.cur.execute(f"""
|
||||||
|
INSERT INTO starsettings VALUES
|
||||||
|
('{reaction}', {channel.id}, '{minimumneeded}', {selfstar}, {interaction.guild_id})
|
||||||
|
""")
|
||||||
|
await interaction.response.send_message("Done!", ephemeral=True)
|
||||||
|
|
||||||
|
@starboardr.subcommand(
|
||||||
|
name="delete",
|
||||||
|
description="Delete a starboard",
|
||||||
|
)
|
||||||
|
async def createstarboard(self, interaction: nextcord.Interaction, channel: nextcord.abc.GuildChannel):
|
||||||
|
await self.bot.cur.execute(f"DELETE FROM starsettings WHERE starchannel = {channel.id}")
|
||||||
|
await interaction.response.send_message("Done!", ephemeral=True)
|
||||||
|
|
||||||
|
def setup(bot: commands.Bot):
|
||||||
|
bot.add_cog(starboard(bot))
|
|
@ -100,7 +100,7 @@ class wordpress(commands.Cog):
|
||||||
description="create a blog post",
|
description="create a blog post",
|
||||||
)
|
)
|
||||||
async def blog(self, interaction: nextcord.Interaction):
|
async def blog(self, interaction: nextcord.Interaction):
|
||||||
await interaction.response.send_modal(BlogModal("https://pastablog.insertapp.net/wp-json/wp/v2/posts",self.bot.blogcredentials))
|
await interaction.response.send_modal(BlogModal("https://blog.pastaland.org/wp-json/wp/v2/posts",self.bot.blogcredentials))
|
||||||
|
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: commands.Bot):
|
||||||
bot.add_cog(wordpress(bot))
|
bot.add_cog(wordpress(bot))
|
Loading…
Reference in a new issue