Skip to content

Commit

Permalink
Multiple Bug Fixes for Release v1.2.1 (#219)
Browse files Browse the repository at this point in the history
* Updated help string to show correct arg positions for roles remove-option (#212)

* No longer pings user when getdefaultroles is used (#213)

* Changed getdefaultroles to use an embed to prevent pings

* removed redundant check

* Updated the look of role reaction menus (#214)

* role menus use a modified generate_embed function to create better looking role menus

* added SSL certificates to gitignore (#215)

* force tweepy to version 3.10.0 (#208)

Force tweepy to latest compatible version with the bot

* Put the command prefix in the activity message (#218)

* Fixed user error strings (#216)

* Gave correct command string for pingme initialisation

* Fixed an issue where the default error handler wouldn't run on some commands

* Updated how the video ID is gotten from a playlist item (#217)
  • Loading branch information
Fluxticks authored Feb 6, 2022
1 parent 865492b commit 55f03cb
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ test-file.py
.vscode
.idea
secrets.env
*.cer
*.key
9 changes: 9 additions & 0 deletions src/esportsbot/DiscordReactableMenus/ExampleMenus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/esportsbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}")
)


Expand Down
6 changes: 2 additions & 4 deletions src/esportsbot/cogs/DefaultRoleCog.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'])
Expand Down
6 changes: 0 additions & 6 deletions src/esportsbot/cogs/EventCategoriesCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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))
2 changes: 1 addition & 1 deletion src/esportsbot/cogs/MusicCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions src/esportsbot/cogs/PingableRolesCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/esportsbot/user_strings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<role menu ID> <emoji option to remove>"
usage = "<emoji option to remove> <role menu ID>"
readme_url = "https://github.com/FragSoc/esports-bot#roles-remove-option-emoji-optional-menu-id"

[help.roles_disable_menu]
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ PyNaCl
aiohttp[speedups]
toml
tornado
tweepy
tweepy==3.10.0

0 comments on commit 55f03cb

Please sign in to comment.