Migrated from NAFF to Interactions.py
continuous-integration/drone Build is passing
Details
continuous-integration/drone Build is passing
Details
This commit is contained in:
parent
eb37f41b45
commit
62902206b0
|
@ -3,7 +3,7 @@ from os import getenv
|
|||
from typing import Optional
|
||||
|
||||
import sentry_sdk as sentry
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Client,
|
||||
Guild,
|
||||
Intents,
|
||||
|
@ -16,12 +16,12 @@ from naff import (
|
|||
RoleSelectMenu,
|
||||
is_owner,
|
||||
check,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
GuildChannel,
|
||||
DM,
|
||||
)
|
||||
from naff.api import events
|
||||
from naff.models.discord.embed import (
|
||||
from interactions.api import events
|
||||
from interactions.models.discord.embed import (
|
||||
Embed,
|
||||
EmbedAuthor,
|
||||
EmbedField,
|
||||
|
@ -169,7 +169,7 @@ class HeimdallrClient(Client):
|
|||
@slash_option(
|
||||
name="module",
|
||||
description="The module to reload",
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
required=True,
|
||||
)
|
||||
async def owner_reload(self, ctx: InteractionContext, module: str):
|
||||
|
@ -188,7 +188,7 @@ class HeimdallrClient(Client):
|
|||
|
||||
try:
|
||||
self.reload_extension(module)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
logging.warn(f"Failed to reload '{module}'.")
|
||||
await ctx.send(f"Failed to reload '{module}'.")
|
||||
else:
|
||||
|
@ -285,8 +285,6 @@ def main():
|
|||
JoinLeave.create_table()
|
||||
|
||||
# Load extensions
|
||||
if (sentry_token := getenv("SENTRY_TOKEN")) is not None:
|
||||
bot.load_extension("naff.ext.sentry", token=sentry_token)
|
||||
bot.load_extension("heimdallr.commands.admin")
|
||||
bot.load_extension("heimdallr.commands.gatekeep")
|
||||
bot.load_extension("heimdallr.commands.quote")
|
||||
|
@ -300,5 +298,4 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import naff.ext.sentry
|
||||
main()
|
||||
|
|
|
@ -6,22 +6,21 @@ for the needs of NLL. So this is to be considered deprecated.
|
|||
|
||||
"""
|
||||
|
||||
from naff import (
|
||||
from interactions import (
|
||||
slash_command,
|
||||
slash_option,
|
||||
Extension,
|
||||
Client,
|
||||
Permissions,
|
||||
InteractionContext,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Embed,
|
||||
Member,
|
||||
EmbedField,
|
||||
EmbedAuthor,
|
||||
Modal,
|
||||
InputText,
|
||||
TextStyles,
|
||||
ChannelTypes,
|
||||
ChannelType,
|
||||
GuildText,
|
||||
)
|
||||
import logging
|
||||
|
@ -52,8 +51,8 @@ class Resources(Extension):
|
|||
@slash_option(
|
||||
name="channel",
|
||||
description="The channel in which submitted/unpublished resources should appear",
|
||||
opt_type=OptionTypes.CHANNEL,
|
||||
channel_types=[ChannelTypes.GUILD_TEXT],
|
||||
opt_type=OptionType.CHANNEL,
|
||||
channel_types=[ChannelType.GUILD_TEXT],
|
||||
)
|
||||
async def adm_set_submitted_resources_channel(
|
||||
self, ctx: InteractionContext, channel: GuildText | None = None
|
||||
|
@ -72,13 +71,11 @@ class Resources(Extension):
|
|||
resource_channel.channel_id = channel.id
|
||||
resource_channel.save()
|
||||
|
||||
await ctx.send(ephemeral=True,
|
||||
await ctx.send(
|
||||
ephemeral=True,
|
||||
content=f"Submitted resource channel set to {channel.mention}."
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@slash_command(
|
||||
name="resources",
|
||||
description="Get or add resources",
|
||||
|
@ -95,7 +92,7 @@ class Resources(Extension):
|
|||
@slash_option(
|
||||
name="page",
|
||||
description="Page of resources to show",
|
||||
opt_type=OptionTypes.INTEGER,
|
||||
opt_type=OptionType.INTEGER,
|
||||
required=False,
|
||||
)
|
||||
async def resources_list(self, ctx: InteractionContext, page: int = 1):
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
# pylint: disable=consider-using-f-string
|
||||
import logging
|
||||
from typing import Optional
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Client,
|
||||
Extension,
|
||||
slash_command,
|
||||
slash_option,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Permissions,
|
||||
InteractionContext,
|
||||
Embed,
|
||||
EmbedField,
|
||||
GuildChannel,
|
||||
ChannelTypes,
|
||||
ChannelType,
|
||||
)
|
||||
|
||||
from database import GuildSettings as GuildSettingsModel, JoinLeave as JoinLeaveModel
|
||||
|
@ -112,8 +112,8 @@ class Admin(Extension):
|
|||
name="channel",
|
||||
description="Channel to set as admin channel",
|
||||
required=True,
|
||||
opt_type=OptionTypes.CHANNEL,
|
||||
channel_types=[ChannelTypes.GUILD_TEXT],
|
||||
opt_type=OptionType.CHANNEL,
|
||||
channel_types=[ChannelType.GUILD_TEXT],
|
||||
)
|
||||
async def adm_set_admin_channel(
|
||||
self, ctx: InteractionContext, channel: GuildChannel
|
||||
|
@ -126,7 +126,6 @@ class Admin(Extension):
|
|||
"Admin channel set to {}".format(channel.mention), ephemeral=True
|
||||
)
|
||||
|
||||
|
||||
@slash_command(
|
||||
name="adm",
|
||||
group_name="set",
|
||||
|
@ -140,7 +139,7 @@ class Admin(Extension):
|
|||
name="enabled",
|
||||
description="Whether or not to use the name filter",
|
||||
required=True,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
async def adm_set_use_name_filter(self, ctx: InteractionContext, enabled: bool) -> None:
|
||||
guild_settings: Optional[GuildSettingsModel]
|
||||
|
@ -163,7 +162,7 @@ class Admin(Extension):
|
|||
name="enabled",
|
||||
description="Whether or not to use gatekeep",
|
||||
required=True,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
async def adm_set_use_gatekeep(self, ctx: InteractionContext, enabled: bool) -> None:
|
||||
guild_settings: Optional[GuildSettingsModel]
|
||||
|
@ -186,8 +185,8 @@ class Admin(Extension):
|
|||
name="channel",
|
||||
description="Channel to set as join/leave messages channel",
|
||||
required=True,
|
||||
opt_type=OptionTypes.CHANNEL,
|
||||
channel_types=[ChannelTypes.GUILD_TEXT],
|
||||
opt_type=OptionType.CHANNEL,
|
||||
channel_types=[ChannelType.GUILD_TEXT],
|
||||
)
|
||||
async def adm_set_join_leave_channel(
|
||||
self, ctx: InteractionContext, channel: GuildChannel
|
||||
|
@ -214,13 +213,13 @@ class Admin(Extension):
|
|||
name="enabled",
|
||||
description="Whether or not to enable the join message",
|
||||
required=True,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
@slash_option(
|
||||
name="message",
|
||||
description="The join message",
|
||||
required=False,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
async def adm_set_join_message(
|
||||
self, ctx: InteractionContext, enabled: bool, message: str = None
|
||||
|
@ -251,13 +250,13 @@ class Admin(Extension):
|
|||
name="enabled",
|
||||
description="Whether or not to enable the leave message",
|
||||
required=True,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
@slash_option(
|
||||
name="message",
|
||||
description="The leave message",
|
||||
required=False,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
async def adm_set_leave_message(
|
||||
self, ctx: InteractionContext, enabled: bool, message: str = None
|
||||
|
|
|
@ -2,7 +2,7 @@ from copy import deepcopy
|
|||
import json
|
||||
from json.decoder import JSONDecodeError
|
||||
import logging
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Client,
|
||||
Extension,
|
||||
slash_command,
|
||||
|
@ -12,7 +12,7 @@ from naff import (
|
|||
ModalContext,
|
||||
context_menu,
|
||||
Permissions,
|
||||
CommandTypes,
|
||||
CommandType,
|
||||
Message,
|
||||
)
|
||||
|
||||
|
@ -22,7 +22,7 @@ from database import BotMessages as BotMessagesModel
|
|||
message_creation_modal = Modal(
|
||||
custom_id="bot-message-create",
|
||||
title="Create a message as the bot",
|
||||
components=[
|
||||
*[
|
||||
ParagraphText(
|
||||
custom_id="embeds",
|
||||
label="Embeds",
|
||||
|
@ -120,7 +120,7 @@ class BotMessages(Extension):
|
|||
# A context menu to allow moderators to edit a bot message.
|
||||
@context_menu(
|
||||
name="Edit bot message",
|
||||
context_type=CommandTypes.MESSAGE,
|
||||
context_type=CommandType.MESSAGE,
|
||||
dm_permission=False,
|
||||
default_member_permissions=Permissions.MANAGE_GUILD,
|
||||
)
|
||||
|
|
|
@ -2,25 +2,25 @@ import logging
|
|||
import random
|
||||
import string
|
||||
from io import BytesIO
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Extension,
|
||||
Client,
|
||||
slash_command,
|
||||
slash_option,
|
||||
context_menu,
|
||||
listen,
|
||||
CommandTypes,
|
||||
CommandType,
|
||||
InteractionContext,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Role,
|
||||
Member,
|
||||
File,
|
||||
SlashCommandChoice,
|
||||
Button,
|
||||
ButtonStyles,
|
||||
ButtonStyle,
|
||||
)
|
||||
from naff.api import events
|
||||
from naff.models.discord.enums import Permissions
|
||||
from interactions.api import events
|
||||
from interactions.models.discord.enums import Permissions
|
||||
from captcha.image import ImageCaptcha
|
||||
from captcha.audio import AudioCaptcha
|
||||
|
||||
|
@ -48,7 +48,7 @@ class Gatekeep(Extension):
|
|||
name="type",
|
||||
description="Type of Gatekeep",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
choices=[
|
||||
SlashCommandChoice(
|
||||
name="Manual",
|
||||
|
@ -79,7 +79,7 @@ class Gatekeep(Extension):
|
|||
name="role",
|
||||
description="Role to grant",
|
||||
required=True,
|
||||
opt_type=OptionTypes.ROLE,
|
||||
opt_type=OptionType.ROLE,
|
||||
)
|
||||
async def set_role_command(self, ctx: InteractionContext, role: Role):
|
||||
gk: GatekeepModel
|
||||
|
@ -100,7 +100,7 @@ class Gatekeep(Extension):
|
|||
name="message",
|
||||
description="Message to send",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
async def set_message_command(self, ctx: InteractionContext, message: str):
|
||||
gk: GatekeepModel
|
||||
|
@ -119,7 +119,7 @@ class Gatekeep(Extension):
|
|||
name="user",
|
||||
description="User to approve",
|
||||
required=True,
|
||||
opt_type=OptionTypes.USER,
|
||||
opt_type=OptionType.USER,
|
||||
)
|
||||
async def approve_command(self, ctx: InteractionContext, user: Member):
|
||||
gk: GatekeepModel
|
||||
|
@ -172,7 +172,7 @@ class Gatekeep(Extension):
|
|||
name="Approve User",
|
||||
dm_permission=False,
|
||||
default_member_permissions=Permissions.MANAGE_ROLES,
|
||||
context_type=CommandTypes.USER,
|
||||
context_type=CommandType.USER,
|
||||
)
|
||||
async def approve_context_menu(self, ctx: InteractionContext):
|
||||
user: Member = ctx.target
|
||||
|
@ -257,7 +257,7 @@ class Gatekeep(Extension):
|
|||
name="captcha",
|
||||
description="The captcha solution",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
async def captcha_command(self, ctx: InteractionContext, captcha: str):
|
||||
|
||||
|
@ -330,7 +330,7 @@ class Gatekeep(Extension):
|
|||
components=Button(
|
||||
label="Regenerate",
|
||||
emoji="🔃",
|
||||
style=ButtonStyles.GRAY,
|
||||
style=ButtonStyle.GRAY,
|
||||
custom_id=f"gatekeep-captcha-regenerate:{member.id}",
|
||||
),
|
||||
)
|
||||
|
@ -346,7 +346,7 @@ class Gatekeep(Extension):
|
|||
components=Button(
|
||||
label="Regenerate",
|
||||
emoji="🔃",
|
||||
style=ButtonStyles.GRAY,
|
||||
style=ButtonStyle.GRAY,
|
||||
custom_id=f"gatekeep-captcha-regenerate:{member.id}",
|
||||
),
|
||||
)
|
||||
|
@ -399,7 +399,7 @@ class Gatekeep(Extension):
|
|||
components=Button(
|
||||
label="Regenerate",
|
||||
emoji="🔃",
|
||||
style=ButtonStyles.GRAY,
|
||||
style=ButtonStyle.GRAY,
|
||||
custom_id=f"gatekeep-captcha-regenerate:{member.id}",
|
||||
),
|
||||
)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# pylint: disable=unsubscriptable-object
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Extension,
|
||||
slash_command,
|
||||
slash_option,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
InteractionContext,
|
||||
Embed,
|
||||
EmbedField,
|
||||
|
@ -14,9 +14,9 @@ from naff import (
|
|||
Client,
|
||||
ActionRow,
|
||||
Button,
|
||||
ButtonStyles,
|
||||
ButtonStyle,
|
||||
)
|
||||
from naff.ext.paginators import Paginator
|
||||
from interactions.ext.paginators import Paginator
|
||||
from peewee import fn
|
||||
from database import (
|
||||
GuildSettings,
|
||||
|
@ -76,7 +76,7 @@ class Infractions(Extension):
|
|||
name="user",
|
||||
description="User to view",
|
||||
required=True,
|
||||
opt_type=OptionTypes.USER,
|
||||
opt_type=OptionType.USER,
|
||||
)
|
||||
async def user_infractions(self, ctx: InteractionContext, user: Member):
|
||||
await ctx.defer(ephemeral=False)
|
||||
|
@ -154,19 +154,19 @@ class Infractions(Extension):
|
|||
name="user",
|
||||
description="User to warn",
|
||||
required=True,
|
||||
opt_type=OptionTypes.USER,
|
||||
opt_type=OptionType.USER,
|
||||
)
|
||||
@slash_option(
|
||||
name="reason",
|
||||
description="Reason for warning",
|
||||
required=False,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
@slash_option(
|
||||
name="weight",
|
||||
description="Severity of warning",
|
||||
required=False,
|
||||
opt_type=OptionTypes.NUMBER,
|
||||
opt_type=OptionType.NUMBER,
|
||||
min_value=0.0,
|
||||
max_value=10.0,
|
||||
)
|
||||
|
@ -174,7 +174,7 @@ class Infractions(Extension):
|
|||
name="silent",
|
||||
description="Silent warning (will not notify user)",
|
||||
required=False,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
async def warn_user(
|
||||
self,
|
||||
|
@ -256,7 +256,7 @@ class Infractions(Extension):
|
|||
name="infraction-id",
|
||||
description="ID of infraction to remove",
|
||||
required=True,
|
||||
opt_type=OptionTypes.INTEGER,
|
||||
opt_type=OptionType.INTEGER,
|
||||
)
|
||||
async def remove_infraction(self, ctx: InteractionContext, infraction_id: int):
|
||||
await ctx.defer(ephemeral=True)
|
||||
|
@ -276,12 +276,12 @@ class Infractions(Extension):
|
|||
ActionRow(
|
||||
Button(
|
||||
custom_id=f"remove-infraction:remove:{infraction.id}",
|
||||
style=ButtonStyles.DANGER,
|
||||
style=ButtonStyle.DANGER,
|
||||
label="Remove infraction",
|
||||
),
|
||||
Button(
|
||||
custom_id=f"remove-infraction:cancel:{infraction.id}",
|
||||
style=ButtonStyles.SECONDARY,
|
||||
style=ButtonStyle.SECONDARY,
|
||||
label="Cancel",
|
||||
),
|
||||
)
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import logging
|
||||
from typing import List, Dict, Set
|
||||
from naff import (
|
||||
from interactions import (
|
||||
AutocompleteContext,
|
||||
Client,
|
||||
Extension,
|
||||
InteractionContext,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
slash_command,
|
||||
slash_option,
|
||||
listen,
|
||||
Button,
|
||||
ButtonStyles,
|
||||
ButtonStyle,
|
||||
events,
|
||||
Message,
|
||||
ChannelTypes,
|
||||
ChannelType,
|
||||
)
|
||||
from database import KeywordNotify as KeywordNotifyModel
|
||||
|
||||
|
@ -51,7 +51,7 @@ class KeywordNotify(Extension):
|
|||
@slash_option(
|
||||
name="keyword",
|
||||
description="The keyword",
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
required=True,
|
||||
max_length=16,
|
||||
)
|
||||
|
@ -76,7 +76,7 @@ class KeywordNotify(Extension):
|
|||
@slash_option(
|
||||
name="keyword",
|
||||
description="The keyword to remove",
|
||||
opt_type=OptionTypes.INTEGER,
|
||||
opt_type=OptionType.INTEGER,
|
||||
required=True,
|
||||
autocomplete=True,
|
||||
)
|
||||
|
@ -149,7 +149,7 @@ class KeywordNotify(Extension):
|
|||
|
||||
@listen(events.MessageCreate)
|
||||
async def on_message_check_keyword(self, event: events.MessageCreate):
|
||||
if event.message.channel.type in [ChannelTypes.DM, ChannelTypes.GROUP_DM]:
|
||||
if event.message.channel.type in [ChannelType.DM, ChannelType.GROUP_DM]:
|
||||
return
|
||||
|
||||
guild = event.message.channel.guild
|
||||
|
@ -188,7 +188,7 @@ class KeywordNotify(Extension):
|
|||
f"{message.author.mention}"
|
||||
),
|
||||
components=Button(
|
||||
style=ButtonStyles.LINK,
|
||||
style=ButtonStyle.LINK,
|
||||
label="Go to message",
|
||||
url=message.jump_url,
|
||||
),
|
||||
|
|
|
@ -3,7 +3,7 @@ import uuid
|
|||
|
||||
from database import GuildSettings
|
||||
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Extension,
|
||||
Client,
|
||||
slash_command,
|
||||
|
@ -11,9 +11,9 @@ from naff import (
|
|||
InteractionContext,
|
||||
ModalContext,
|
||||
Permissions,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Button,
|
||||
ButtonStyles,
|
||||
ButtonStyle,
|
||||
listen,
|
||||
events,
|
||||
Modal,
|
||||
|
@ -38,13 +38,13 @@ class ModMail(Extension):
|
|||
@slash_option(
|
||||
name="button-text",
|
||||
description="The text that should be displayed on the button.",
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
required=True
|
||||
)
|
||||
@slash_option(
|
||||
name="notify-role",
|
||||
description="Role that should be tagged upon creation of the modmail thread.",
|
||||
opt_type=OptionTypes.ROLE,
|
||||
opt_type=OptionType.ROLE,
|
||||
required=True
|
||||
)
|
||||
async def adm_create_modmail_button(self, ctx: InteractionContext, button_text: str, role: Role):
|
||||
|
@ -52,7 +52,7 @@ class ModMail(Extension):
|
|||
|
||||
await ctx.channel.send(
|
||||
components=Button(
|
||||
style=ButtonStyles.GREEN,
|
||||
style=ButtonStyle.GREEN,
|
||||
label=button_text,
|
||||
custom_id=f"send-modmail-button:{role.id}"
|
||||
)
|
||||
|
@ -131,7 +131,7 @@ class ModMail(Extension):
|
|||
"Message created",
|
||||
ephemeral=True,
|
||||
components=Button(
|
||||
style=ButtonStyles.LINK,
|
||||
style=ButtonStyle.LINK,
|
||||
label="Go to message",
|
||||
url=msg.jump_url,
|
||||
)
|
||||
|
|
|
@ -5,20 +5,20 @@ from datetime import datetime, timedelta
|
|||
import logging
|
||||
import json
|
||||
from typing import List, Tuple
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Client,
|
||||
Extension,
|
||||
slash_command,
|
||||
slash_option,
|
||||
InteractionContext,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Permissions,
|
||||
Modal,
|
||||
ShortText,
|
||||
ParagraphText,
|
||||
ModalContext,
|
||||
Button,
|
||||
ButtonStyles,
|
||||
ButtonStyle,
|
||||
Embed,
|
||||
spread_to_rows,
|
||||
Message,
|
||||
|
@ -28,8 +28,8 @@ from naff import (
|
|||
GuildText,
|
||||
PartialEmoji,
|
||||
)
|
||||
from naff.api import events
|
||||
from naff.client.errors import HTTPException
|
||||
from interactions.api import events
|
||||
from interactions.client.errors import HTTPException
|
||||
|
||||
from peewee import fn
|
||||
from database import Polls as PollsModel, PollVotes as PollVotesModel
|
||||
|
@ -166,19 +166,19 @@ class Polls(Extension):
|
|||
name="title",
|
||||
description="Title of the poll",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
@slash_option(
|
||||
name="duration",
|
||||
description="Duration of the poll in minutes",
|
||||
required=False,
|
||||
opt_type=OptionTypes.INTEGER,
|
||||
opt_type=OptionType.INTEGER,
|
||||
)
|
||||
@slash_option(
|
||||
name="multiple-choice",
|
||||
description="If users can vote for multiple options",
|
||||
required=False,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
async def create_poll( # pylint: disable=too-many-locals
|
||||
self,
|
||||
|
@ -268,7 +268,7 @@ class Polls(Extension):
|
|||
buttons.append(
|
||||
Button(
|
||||
emoji=emoji,
|
||||
style=ButtonStyles.PRIMARY,
|
||||
style=ButtonStyle.PRIMARY,
|
||||
custom_id=f"poll-vote:{poll_entry.id}:{i}",
|
||||
)
|
||||
)
|
||||
|
@ -278,7 +278,7 @@ class Polls(Extension):
|
|||
Button(
|
||||
emoji="🔒",
|
||||
label="Lock",
|
||||
style=ButtonStyles.DANGER,
|
||||
style=ButtonStyle.DANGER,
|
||||
custom_id=f"poll-lock:{poll_entry.id}",
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import re
|
||||
import logging
|
||||
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Extension,
|
||||
slash_command,
|
||||
slash_option,
|
||||
InteractionContext,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Client,
|
||||
)
|
||||
from naff.models.discord.enums import ButtonStyles, Permissions
|
||||
from naff.models.discord.embed import Embed, EmbedAuthor, EmbedField
|
||||
from naff.models.discord.components import ActionRow, Button
|
||||
from interactions.models.discord.enums import ButtonStyle, Permissions
|
||||
from interactions.models.discord.embed import Embed, EmbedAuthor, EmbedField
|
||||
from interactions.models.discord.components import ActionRow, Button
|
||||
|
||||
|
||||
class QuoteExtension(Extension):
|
||||
|
@ -23,7 +23,7 @@ class QuoteExtension(Extension):
|
|||
name="url",
|
||||
description="Message URL",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
async def quote_command(self, ctx: InteractionContext, url: str):
|
||||
|
||||
|
@ -83,7 +83,7 @@ class QuoteExtension(Extension):
|
|||
components: list[ActionRow] = [
|
||||
ActionRow(
|
||||
Button(
|
||||
style=ButtonStyles.LINK,
|
||||
style=ButtonStyle.LINK,
|
||||
emoji="🔗",
|
||||
url=url,
|
||||
)
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
# pylint: disable=not-an-iterable
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
import logging
|
||||
from naff import (
|
||||
from interactions import (
|
||||
Extension,
|
||||
Client,
|
||||
slash_command,
|
||||
slash_option,
|
||||
OptionTypes,
|
||||
OptionType,
|
||||
Permissions,
|
||||
InteractionContext,
|
||||
Role,
|
||||
Embed,
|
||||
AutocompleteContext,
|
||||
StringSelectMenu,
|
||||
SelectOption,
|
||||
StringSelectOption,
|
||||
listen,
|
||||
context_menu,
|
||||
CommandTypes,
|
||||
CommandType,
|
||||
Message,
|
||||
)
|
||||
from naff.api import events
|
||||
from interactions.api import events
|
||||
from database import (
|
||||
SelfRoles as SelfRolesModel,
|
||||
SelfRoleGroups as SelfRoleGroupsModel,
|
||||
|
@ -40,19 +40,19 @@ class SelfRoles(Extension):
|
|||
default_member_permissions=Permissions.MANAGE_ROLES,
|
||||
)
|
||||
@slash_option(
|
||||
name="role", description="Role to add", required=True, opt_type=OptionTypes.ROLE
|
||||
name="role", description="Role to add", required=True, opt_type=OptionType.ROLE
|
||||
)
|
||||
@slash_option(
|
||||
name="description",
|
||||
description="Description of the role",
|
||||
required=False,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
@slash_option(
|
||||
name="requires",
|
||||
description="Role required to add this role",
|
||||
required=False,
|
||||
opt_type=OptionTypes.ROLE,
|
||||
opt_type=OptionType.ROLE,
|
||||
)
|
||||
async def role_admin_add(
|
||||
self,
|
||||
|
@ -90,7 +90,7 @@ class SelfRoles(Extension):
|
|||
name="role",
|
||||
description="Role to remove",
|
||||
required=True,
|
||||
opt_type=OptionTypes.ROLE,
|
||||
opt_type=OptionType.ROLE,
|
||||
)
|
||||
async def role_admin_remove(self, ctx: InteractionContext, role: Role):
|
||||
await ctx.defer(ephemeral=True)
|
||||
|
@ -116,19 +116,19 @@ class SelfRoles(Extension):
|
|||
name="group",
|
||||
description="Group to add",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
@slash_option(
|
||||
name="description",
|
||||
description="Description of the group",
|
||||
required=False,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
@slash_option(
|
||||
name="exclusive",
|
||||
description="Whether each role in this group is exclusive",
|
||||
required=False,
|
||||
opt_type=OptionTypes.BOOLEAN,
|
||||
opt_type=OptionType.BOOLEAN,
|
||||
)
|
||||
async def role_group_add_group(
|
||||
self,
|
||||
|
@ -164,7 +164,7 @@ class SelfRoles(Extension):
|
|||
name="group",
|
||||
description="Group to remove",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
)
|
||||
async def role_group_remove_group(self, ctx: InteractionContext, group: str):
|
||||
await ctx.defer(ephemeral=True)
|
||||
|
@ -195,14 +195,14 @@ class SelfRoles(Extension):
|
|||
name="group",
|
||||
description="Group to add the role to",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
@slash_option(
|
||||
name="role",
|
||||
description="Role to add to the group",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
async def role_group_add_role(self, ctx: InteractionContext, group: str, role: str):
|
||||
|
@ -265,14 +265,14 @@ class SelfRoles(Extension):
|
|||
name="group",
|
||||
description="Group to remove the role from",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
@slash_option(
|
||||
name="role",
|
||||
description="Role to remove from the group",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
async def role_group_remove_role(
|
||||
|
@ -398,7 +398,7 @@ class SelfRoles(Extension):
|
|||
name="group",
|
||||
description="Group to generate the message from",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
async def role_group_generate(self, ctx: InteractionContext, group: str):
|
||||
|
@ -427,7 +427,7 @@ class SelfRoles(Extension):
|
|||
|
||||
options = []
|
||||
for role in roles_q:
|
||||
opt = SelectOption(
|
||||
opt = StringSelectOption(
|
||||
label=role.role_name,
|
||||
value=str(role.role_id),
|
||||
description=role.role_description,
|
||||
|
@ -535,7 +535,7 @@ class SelfRoles(Extension):
|
|||
|
||||
@context_menu(
|
||||
name="Regenerate role group message",
|
||||
context_type=CommandTypes.MESSAGE,
|
||||
context_type=CommandType.MESSAGE,
|
||||
dm_permission=False,
|
||||
default_member_permissions=Permissions.MANAGE_ROLES,
|
||||
)
|
||||
|
@ -591,7 +591,7 @@ class SelfRoles(Extension):
|
|||
|
||||
options = []
|
||||
for role in roles_q:
|
||||
opt = SelectOption(
|
||||
opt = StringSelectOption(
|
||||
label=role.role_name,
|
||||
value=str(role.role_id),
|
||||
description=role.role_description,
|
||||
|
@ -630,7 +630,7 @@ class SelfRoles(Extension):
|
|||
name="role",
|
||||
description="Role to add",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
async def role_add(self, ctx: InteractionContext, role: str):
|
||||
|
@ -719,7 +719,7 @@ class SelfRoles(Extension):
|
|||
name="role",
|
||||
description="Role to remove",
|
||||
required=True,
|
||||
opt_type=OptionTypes.STRING,
|
||||
opt_type=OptionType.STRING,
|
||||
autocomplete=True,
|
||||
)
|
||||
async def role_remove(self, ctx: InteractionContext, role: str):
|
||||
|
|
|
@ -301,6 +301,36 @@ files = [
|
|||
[package.extras]
|
||||
graph = ["objgraph (>=1.7.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "discord-py-interactions"
|
||||
version = "5.5.1"
|
||||
description = "Easy, simple, scalable and modular: a Python API wrapper for interactions."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.10"
|
||||
files = [
|
||||
{file = "discord-py-interactions-5.5.1.tar.gz", hash = "sha256:130bdc1b22d44562d4bacf946d4d2d2b0b763ee6646b21c8f7ddf8de93ad348b"},
|
||||
{file = "discord_py_interactions-5.5.1-py3-none-any.whl", hash = "sha256:b42080456432043e68f8812f0763a4acde3dc3a41654addf87717862c67bb65d"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
aiohttp = "*"
|
||||
attrs = ">=22.1"
|
||||
discord-typings = ">=0.5.1"
|
||||
emoji = "*"
|
||||
tomli = "*"
|
||||
|
||||
[package.extras]
|
||||
all = ["Brotli", "PyNaCl (>=1.5.0,<1.6)", "aioconsole (>=0.6.0)", "aiodns", "faust-cchardet", "jurigged", "orjson", "sentry-sdk", "uvloop"]
|
||||
console = ["aioconsole (>=0.6.0)"]
|
||||
dev = ["Brotli", "PyNaCl (>=1.5.0,<1.6)", "aioconsole (>=0.6.0)", "aiodns", "faust-cchardet", "jurigged", "mkdocs-autorefs", "mkdocs-awesome-pages-plugin", "mkdocs-git-committers-plugin-2", "mkdocs-git-revision-date-localized-plugin", "mkdocs-material", "mkdocs-minify-plugin", "mkdocstrings-python", "orjson", "pre-commit", "pytest", "pytest-asyncio", "pytest-cov", "python-dotenv", "sentry-sdk", "typeguard", "uvloop"]
|
||||
docs = ["Brotli", "PyNaCl (>=1.5.0,<1.6)", "aioconsole (>=0.6.0)", "aiodns", "faust-cchardet", "jurigged", "mkdocs-autorefs", "mkdocs-awesome-pages-plugin", "mkdocs-git-committers-plugin-2", "mkdocs-git-revision-date-localized-plugin", "mkdocs-material", "mkdocs-minify-plugin", "mkdocstrings-python", "orjson", "sentry-sdk", "uvloop"]
|
||||
jurigged = ["jurigged"]
|
||||
sentry = ["sentry-sdk"]
|
||||
speedup = ["Brotli", "aiodns", "faust-cchardet", "orjson", "uvloop"]
|
||||
tests = ["pytest", "pytest-asyncio", "pytest-cov", "python-dotenv", "typeguard"]
|
||||
voice = ["PyNaCl (>=1.5.0,<1.6)"]
|
||||
|
||||
[[package]]
|
||||
name = "discord-typings"
|
||||
version = "0.5.1"
|
||||
|
@ -1385,4 +1415,4 @@ multidict = ">=4.0"
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "5b7f61228c5907b87063f940377c0c2f2abeb8c2454e1ab2afa7c61374f2fbc5"
|
||||
content-hash = "a7589e4471c957985f39101d8051738dc0102f2516d16d217ed28b0d5a1ed47b"
|
||||
|
|
|
@ -13,6 +13,7 @@ peewee = "^3.15.1"
|
|||
naff = "2.1.0"
|
||||
python-dotenv = "^0.20.0"
|
||||
captcha = "^0.4"
|
||||
discord-py-interactions = "^5.5.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = "^22.6.0"
|
||||
|
|
Loading…
Reference in New Issue