diff --git a/.gitignore b/.gitignore index b58135ff..176d046c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ test-file.py .vscode .idea secrets.env +*.cer +*.key diff --git a/src/esportsbot/DiscordReactableMenus/ExampleMenus.py b/src/esportsbot/DiscordReactableMenus/ExampleMenus.py index 3d4b3f31..72d6091d 100644 --- a/src/esportsbot/DiscordReactableMenus/ExampleMenus.py +++ b/src/esportsbot/DiscordReactableMenus/ExampleMenus.py @@ -57,6 +57,15 @@ def __init__(self, **kwargs): super().__init__(**kwargs) + def generate_embed(self) -> Embed: + embed = Embed(title=f"{self.title} {self.title_suffix}", description=self.description, colour=self.colour) + for emoji_id in self.options: + emoji = self.options.get(emoji_id).get("emoji").discord_emoji + descriptor = self.options.get(emoji_id).get("descriptor") + embed.add_field(name="ā€‹", value=f"{emoji} ā€” {descriptor}", inline=self.use_inline) + + return embed + async def react_add_func(self, payload: RawReactionActionEvent) -> bool: message_id: int = payload.message_id channel_id: int = payload.channel_id diff --git a/src/esportsbot/bot.py b/src/esportsbot/bot.py index 76ea176a..eed711e1 100644 --- a/src/esportsbot/bot.py +++ b/src/esportsbot/bot.py @@ -21,7 +21,7 @@ async def on_ready(): await client.change_presence( status=discord.Status.dnd, activity=discord.Activity(type=discord.ActivityType.listening, - name="your commands") + name=f"commands using {os.getenv('COMMAND_PREFIX')}") ) diff --git a/src/esportsbot/cogs/DefaultRoleCog.py b/src/esportsbot/cogs/DefaultRoleCog.py index e5d71560..392701a2 100644 --- a/src/esportsbot/cogs/DefaultRoleCog.py +++ b/src/esportsbot/cogs/DefaultRoleCog.py @@ -1,4 +1,5 @@ from discord.ext import commands, tasks +from discord import Embed from esportsbot.db_gateway import DBGatewayActions from esportsbot.models import GuildInfo, DefaultRoles from esportsbot.base_functions import role_id_from_mention @@ -54,9 +55,6 @@ async def check_pending_members(self): self.pending_members.remove(member) async def apply_roles(self, member): - guild = DBGatewayActions().get(GuildInfo, guild_id=member.guild.id) - if not guild: - return # Get all the default role for the server from database guild_default_roles = DBGatewayActions().list(DefaultRoles, guild_id=member.guild.id) # Check to see if any roles exist @@ -144,7 +142,7 @@ async def getdefaultroles(self, ctx): apply_roles = [ctx.author.guild.get_role(role.role_id) for role in guild_default_roles] # Return all the default roles to the user await ctx.channel.send( - self.STRINGS['default_role_get'].format(role_ids=(' '.join(f'<@&{x.id}>' for x in apply_roles))) + embed=Embed(title=self.STRINGS['default_role_get'], description="ā€” "+('\nā€” '.join(f'<@&{x.id}>' for x in apply_roles))) ) else: await ctx.channel.send(self.STRINGS['default_role_missing']) diff --git a/src/esportsbot/cogs/EventCategoriesCog.py b/src/esportsbot/cogs/EventCategoriesCog.py index dd6cea76..e2966885 100644 --- a/src/esportsbot/cogs/EventCategoriesCog.py +++ b/src/esportsbot/cogs/EventCategoriesCog.py @@ -42,7 +42,6 @@ class EventCategoriesCog(commands.Cog): def __init__(self, bot): self.bot = bot self.user_strings = bot.STRINGS["event_categories"] - self.command_error_message = bot.STRINGS["command_error_generic"] self.db = DBGatewayActions() self.event_menus = defaultdict(dict) self.logger = logging.getLogger(__name__) @@ -555,11 +554,6 @@ async def generic_error_handler(self, context: commands.Context, error: commands await context.reply(self.user_strings["bot_missing_perms"].format(permissions=permissions)) return - # If an error occurred that wasn't one of the above, send a message telling the user to contact a dev as something - # unexpected has occurred. - await context.reply(self.command_error_message) - raise error - def setup(bot): bot.add_cog(EventCategoriesCog(bot)) diff --git a/src/esportsbot/cogs/MusicCog.py b/src/esportsbot/cogs/MusicCog.py index 75b0d43c..459a3266 100644 --- a/src/esportsbot/cogs/MusicCog.py +++ b/src/esportsbot/cogs/MusicCog.py @@ -526,7 +526,7 @@ def url_from_response(response): if response.get("kind") == "youtube#video": video_id = response.get("id") else: - video_id = response.get("resourceId").get("videoId") + video_id = response.get("snippet").get("resourceId").get("videoId") return "https://youtube.com/watch?v={}".format(video_id) @staticmethod diff --git a/src/esportsbot/cogs/PingableRolesCog.py b/src/esportsbot/cogs/PingableRolesCog.py index 60f752a7..70472a8c 100644 --- a/src/esportsbot/cogs/PingableRolesCog.py +++ b/src/esportsbot/cogs/PingableRolesCog.py @@ -51,7 +51,6 @@ def __init__(self, bot): self.bot = bot self.db = DBGatewayActions() self.user_strings = self.bot.STRINGS["pingable_roles"] - self.command_error_message = bot.STRINGS["command_error_generic"] self.logger = logging.getLogger(__name__) self.guild_settings = self.load_guild_settings() # Guild ID: Pingable_settings as dict @@ -64,6 +63,8 @@ def __init__(self, bot): self.current_menu = None self.current_role = None self.on_cooldown = False + + self.init_command_string = "pingme settings default-settings" self.logger.info(f"Finished loading {__name__}... waiting for ready") @commands.Cog.listener() @@ -604,7 +605,7 @@ async def get_guild_in_settings(self, context): await context.send( self.user_strings["needs_initialising"].format( prefix=self.bot.command_prefix, - command="pingme settings default-settings" + command=self.init_command_string ) ) return None @@ -637,7 +638,7 @@ async def get_guild_settings(self, context: commands.Context): if not guild_settings: await context.send( self.user_strings["needs_initialising"].format(prefix=self.bot.command_prefix, - command="default-settings") + command=self.init_command_string) ) return @@ -754,7 +755,7 @@ async def set_role_cooldown(self, context: commands.Context, role_cooldown: int) await context.send( self.user_strings["needs_initialising"].format( prefix=self.bot.command_prefix, - command="pingme settings default-settings" + command=self.init_command_string ) ) return @@ -822,7 +823,7 @@ async def create_role(self, context: commands.Context, role_name: str, poll_leng await context.send( self.user_strings["needs_initialising"].format( prefix=self.bot.command_prefix, - command="pingme settings default-settings" + command=self.init_command_string ) ) return @@ -1071,9 +1072,6 @@ async def integer_parse_error(self, context: commands.Context, error: commands.C await context.reply(self.user_strings["invalid_argument"]) return - await context.reply(self.command_error_message) - raise error - @change_pingable_role_cooldown.error async def role_cooldown_error(self, context: commands.Context, error: commands.CommandError): """ diff --git a/src/esportsbot/user_strings.toml b/src/esportsbot/user_strings.toml index 20c56a51..cc0225d2 100644 --- a/src/esportsbot/user_strings.toml +++ b/src/esportsbot/user_strings.toml @@ -381,7 +381,7 @@ readme_url = "https://github.com/FragSoc/esports-bot#roles-add-option-optional-m [help.roles_remove_option] help_string = "Remove an option from an existing role menu." description = "Using the emoji to identify which option you want to remove from the role menu, remove the option from that given menu." -usage = " " +usage = " " readme_url = "https://github.com/FragSoc/esports-bot#roles-remove-option-emoji-optional-menu-id" [help.roles_disable_menu] @@ -529,7 +529,7 @@ default_roles_set_empty = "No roles were passed, please review your usage" default_roles_set_error = "Error occurred during this operation, please check that you have formatted these inputs correctly" default_roles_set_log = "{author_mention} has set the default role(s) to: {roles}" -default_role_get = "Default role(s) are set to {role_ids}" +default_role_get = "Default role(s) are set to:" default_role_removed = "Default role(s) are removed" default_role_removed_log = "{author_mention} has removed the default role" diff --git a/src/requirements.txt b/src/requirements.txt index 5641e181..95c25200 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -12,4 +12,4 @@ PyNaCl aiohttp[speedups] toml tornado -tweepy +tweepy==3.10.0