Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support user installation #20

Merged
merged 6 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ invite.txt
*.bat
cogs/cache/
.vscode/
*.code-workspace
*.code-workspace
pycord/
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def send_message_to_owner(self, message: str):
debug_guilds = [int(os.getenv("DEBUG_GUILD_ID")), int(os.getenv("DEBUG_GUILD_ID2"))] # type: ignore
else: # is NOT debug mode
token = os.getenv("DISCORD_TOKEN")
debug_guilds = []
debug_guilds = None

bot = CDNBot(
command_prefix="!",
Expand Down
10 changes: 0 additions & 10 deletions cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def __init__(self, bot: bridge.Bot):
admin_commands = discord.SlashCommandGroup(
name="admin",
description="Administration commands",
guild_only=True,
guild_ids=HOME_GUILD,
)

Expand Down Expand Up @@ -83,15 +82,6 @@ async def force_update_check(self, ctx: bridge.BridgeApplicationContext):
await watcher.cdn_auto_refresh()
await ctx.respond("Updates complete.", ephemeral=True, delete_after=300)

@commands.is_owner()
@admin_commands.command(name="nuxtest")
async def nuxtest(self, ctx: bridge.BridgeApplicationContext):
guild = ctx.guild
nux_cog = self.bot.get_cog("GuildNUX")
message = await nux_cog.get_nux_message(guild)

await ctx.respond(message, ephemeral=True, delete_after=300)

# funni commands

@bridge.bridge_command(
Expand Down
4 changes: 2 additions & 2 deletions cogs/nux.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
logger = logging.getLogger("discord.nux")


class GuildNUX(commands.Cog):
class NUX(commands.Cog):
def __init__(self, bot: bridge.Bot):
self.bot = bot
self.guild_cfg = GuildCFG()
Expand Down Expand Up @@ -69,4 +69,4 @@ async def on_guild_join(self, guild: discord.Guild):


def setup(bot):
bot.add_cog(GuildNUX(bot))
bot.add_cog(NUX(bot))
32 changes: 27 additions & 5 deletions cogs/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,26 @@ async def handle_command_error(self, ctx: discord.ApplicationContext, exception)

# DISCORD COMMANDS

@bridge.bridge_command(name="cdndata")
@bridge.bridge_command(
name="cdndata",
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
async def cdn_data(self, ctx: bridge.BridgeApplicationContext):
"""Returns a paginator with the currently cached CDN data."""
logger.debug("Generating paginator to display CDN data...")
paginator = self.build_paginator_for_current_build_data()
await paginator.respond(ctx.interaction, ephemeral=True)

@bridge.bridge_command(name="branches")
@bridge.bridge_command(
name="branches",
contexts={
discord.InteractionContextType.guild,
discord.InteractionContextType.bot_dm,
},
)
@commands.cooldown(1, COOLDOWN, commands.BucketType.user)
async def cdn_branches(self, ctx: bridge.BridgeApplicationContext):
"""Returns all observable branches."""
Expand All @@ -515,7 +527,9 @@ async def cdn_branches(self, ctx: bridge.BridgeApplicationContext):
)

watchlist_commands = discord.SlashCommandGroup(
name="watchlist", description="Watchlist commands", guild_only=True
name="watchlist",
description="Watchlist commands",
contexts={discord.InteractionContextType.guild},
)

@watchlist_commands.command(
Expand Down Expand Up @@ -654,7 +668,9 @@ async def cdn_watchlist(self, ctx: bridge.BridgeApplicationContext):
)

channel_commands = discord.SlashCommandGroup(
name="channel", description="Notification channel commands", guild_only=True
name="channel",
description="Notification channel commands",
contexts={discord.InteractionContextType.guild},
)

@channel_commands.command(
Expand Down Expand Up @@ -715,7 +731,13 @@ async def cdn_last_update(self, ctx: bridge.BridgeApplicationContext):
)

dm_commands = discord.SlashCommandGroup(
name="dm", description="DM notification commands"
name="dm",
description="DM notification commands",
contexts={
discord.InteractionContextType.private_channel,
discord.InteractionContextType.bot_dm,
},
integration_types={discord.IntegrationType.user_install},
)

@dm_commands.command(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
py-cord==2.5.0
py-cord[speed]==2.6.0
httpx[http2]==0.27.0
tweepy[async]==4.14.0
pyyaml==6.0.1
Loading