Skip to content

Commit

Permalink
fixed new errors with list and configure
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKassab committed Dec 5, 2023
1 parent e309bd4 commit dda1cd9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bot/cogs/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def __init__(self, bot):
async def set_update_channel(self, interaction: discord.Interaction):
await interaction.response.send_message("Attempting to set current channel for updates...", ephemeral=True)
if not self.bot.db.is_guild_exist(interaction.guild_id):
self.bot.db.add_guild(Guild(interaction.guild_id, interaction.channel_id))
self.bot.db.add_guild(interaction.guild_id, interaction.channel_id)
await interaction.edit_original_response(content="Channel successfully configured for updates. You "
f"may begin following artists using `/{FOLLOW_COMMAND}`.")
else:
guild = self.bot.db.get_guild(interaction.guild_id)
guild = self.bot.db.get_guild_by_id(interaction.guild_id)
guild.music_channel_id = interaction.channel_id
self.bot.db.update_guild(guild)
await interaction.edit_original_response(content="Current channel successfully configured for updates.")
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ALREADY_FOLLOW_FORMAT_MESSAGE = 'This server is already following %s! We\'ve assigned you the corresponding role.'

FAILED_MESSAGE = "Failed to follow artist."
ATTEMPT_FOLLOW_MESSAGE = "'Attempting to follow artist...'"
ATTEMPT_FOLLOW_MESSAGE = "Attempting to follow artist..."
CONFIGURE_CHANNEL_MESSAGE = f"A server admin must first use `/{SET_COMMAND}` to configure a channel to send updates to."
ARTIST_NOT_FOUND_MESSAGE = "Artist not found, please make sure you are providing a valid spotify artist url"
MISSING_MANAGE_ROLES_MESSAGE = "Bot is missing Manage Roles permission."
Expand Down
12 changes: 9 additions & 3 deletions bot/cogs/list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from discord.ext import commands
from discord import app_commands
from discord.ui import Select, View, Button
from discord.utils import get

from helpers import get_fan_role_name
from services.fanbotdatabase import Artist
import discord
from settings import LIST_COMMAND
Expand All @@ -19,10 +22,12 @@ def __init__(self, bot):
)
async def list_follows(self, interaction: discord.Interaction):
guild = self.bot.db.get_guild_by_id(guild_id=interaction.guild_id)
if guild is None or len(guild.artists) == 0:
if guild is None or len(guild.artist_ids) == 0:
await interaction.response.send_message("No artists currently followed.", ephemeral=True)
return
artists = guild.artists
artists = []
for artist_id in guild.artist_ids:
artists.append(self.bot.db.get_artist_by_id(artist_id))
artists = sorted(artists, key=lambda x: x.name)
guild = self.bot.get_guild(interaction.guild_id)
await interaction.response.send_message(content=DEF_MSG + '1', view=RoleAssignView(artists, guild),
Expand All @@ -38,7 +43,8 @@ def __init__(self, artists: [Artist], guild: discord.Guild):
self.select_options = []
self.guild = guild
for artist in artists:
self.select_options.append(discord.SelectOption(label=artist.name, value=artist.role_id))
role_id = get(guild.roles, name=get_fan_role_name(artist.name)).id
self.select_options.append(discord.SelectOption(label=artist.name, value=str(role_id)))
max_values = len(self.select_options) if len(self.select_options) < 25 else 25

self.select = Select(placeholder="Select an artist", options=self.select_options[:25], max_values=max_values)
Expand Down

0 comments on commit dda1cd9

Please sign in to comment.