Skip to content

Commit

Permalink
Convert interaction to ctx for hybrid command
Browse files Browse the repository at this point in the history
  • Loading branch information
tookender committed Aug 25, 2024
1 parent e843f28 commit 39daa6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ WORKDIR /main

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

RUN pip install --no-cache-dir -r requirements.txt && \
pip list

COPY . .

EXPOSE 6969
Expand Down
20 changes: 10 additions & 10 deletions extensions/config/levelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ async def view_message(self, interaction: Interaction, button: discord.ui.Button
return await interaction.response.send_message(f"**Announcement Message:** `{message}`", ephemeral=True)


async def update_message(interaction: Interaction, edit: Optional[bool] = True):
async def update_message(ctx, edit: Optional[bool] = True):
try:
if interaction.guild:
data = await interaction.client.pool.fetchrow(
if ctx.guild:
data = await ctx.client.pool.fetchrow(
"SELECT levelling_enabled, levelling_announce, levelling_channel, levelling_message, levelling_multiplier FROM guilds WHERE guild_id = $1",
interaction.guild.id,
ctx.guild.id,
)

if not data:
await interaction.client.pool.execute("INSERT INTO guilds(guild_id) VALUES ($1)", interaction.guild.id)
await update_message(interaction, edit)
await ctx.client.pool.execute("INSERT INTO guilds(guild_id) VALUES ($1)", ctx.guild.id)
await update_message(ctx, edit)

bool_emojis = {
True: "🟩",
Expand All @@ -167,20 +167,20 @@ async def update_message(interaction: Interaction, edit: Optional[bool] = True):
f"```\n"
f"Enabled - {bool_emojis[data[0]]}\n"
f"Announce - {bool_emojis[data[1]]}\n"
f"Announcement Channel - {interaction.guild.get_channel(data[2]) if data[2] else bool_emojis[data[2]] + ' direct'}\n"
f"Announcement Channel - {ctx.guild.get_channel(data[2]) if data[2] else bool_emojis[data[2]] + ' direct'}\n"
f"Announcement Message - {bool_emojis[True] + ' view below' if data[3] else bool_emojis[None]}\n"
f"Banned Roles - soon™\n"
f"XP Multiplier - {data[4]}\n"
f"```",
)

if not edit:
return await interaction.response.send_message(embed=embed, view=ConfigLevelling())
return await ctx.send(embed=embed, view=ConfigLevelling())

return await interaction.response.edit_message(embed=embed, view=ConfigLevelling())
return await ctx.message.edit(embed=embed, view=ConfigLevelling())

except Exception as e:
return await interaction.response.send_message(f"An error occurred: {traceback.format_exception(e)}", ephemeral=True)
return await ctx.send(f"An error occurred: {traceback.format_exception(e)}", ephemeral=True)


class LevellingConfig(ConfigBase):
Expand Down

0 comments on commit 39daa6c

Please sign in to comment.