Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
Added option to leaderboard command
Browse files Browse the repository at this point in the history
Other minor fixes
  • Loading branch information
vasll committed Apr 29, 2023
1 parent 8761f41 commit e0c0ae1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cogs/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def configure(
str, description="The default task title for new tasks", required=False
)
):
await ctx.response.defer()
await ctx.response.defer(ephemeral=True)
embed = Embed(title=":gear: Bot configuration", colour=Colour.green())

# Get role names from server
Expand Down
9 changes: 6 additions & 3 deletions cogs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,18 @@ async def add_task(


@discord.command(name="leaderboard", description="Shows the current leaderboard of tasks for this server")
async def leaderboard(self, ctx: ApplicationContext):
await ctx.response.defer(ephemeral=True)
async def leaderboard(
self, ctx: ApplicationContext,
hide_message: Option(bool, description="Only you will see the leaderboard", default=True, required=False)
):
await ctx.response.defer(ephemeral=hide_message)

try:
leaderboard_entries = await queries.get_guild_leaderboard(ctx.guild.id)
except Exception as e:
logger.error(f"Exception while fetching leaderboard for guild {ctx.guild.id}: {e}")

embed = discord.Embed(title="TaskBot leaderboard", colour=Colour.gold())
embed = discord.Embed(title="TaskBot leaderboard for this server", colour=Colour.gold())

leaderboard_users_count = 0
for entry in leaderboard_entries:
Expand Down
2 changes: 1 addition & 1 deletion taskbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class TaskBot(Bot):
intents = discord.Intents(
members=True, presences=True, messages=True, guilds=True, bans=True, message_content=True
members=True, messages=True, guilds=True, bans=True, message_content=True
)

def __init__(self):
Expand Down
4 changes: 3 additions & 1 deletion views/role_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def add_roles(self, button: Button, interaction: Interaction):
# Get guild configuration and tasks role
db_guild = await queries.get_guild(interaction.guild.id)
if db_guild is None:
return await interaction.channel.send("Server configuration not found. Run the `/configure` command first.")
return await interaction.response.send_message(
"Server configuration not found. Run the `/configure` command first.", ephemeral=True
)

# Get the @tasks role from the server
try:
Expand Down

0 comments on commit e0c0ae1

Please sign in to comment.