Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roleboard #46

Open
wants to merge 108 commits into
base: master
Choose a base branch
from
Open

Roleboard #46

wants to merge 108 commits into from

Conversation

gmcaguilar
Copy link
Contributor

Merge Rolecall v2 to master for publishing

Chovin and others added 30 commits October 9, 2017 13:29
## To make a commit, type your commit message and press CTRL-ENTER. To cancel
## the commit, close the window. To sign off on the commit, press CTRL-S.
##
## You may also reference or close a GitHub issue with this commit.  To do so,
## type `#` followed by the `tab` key.  You will be shown a list of issues
## related to the current repo.  You may also type `owner/repo#` plus the `tab`
## key to reference an issue in a different GitHub repo.

 rolecall/UI Specification |   9 ++++++++-
 rolecall/sample.png       | Bin 287260 -> 0 bytes
 2 files changed, 8 insertions(+), 1 deletion(-)
next_key = self.reaction_user_queue.pop()
reaction = self.reaction_queue.pop(next_key)
await self.process_event(reaction)
await asyncio.sleep(0.0001)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably wait longer than this 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated ridiculous sleep time to a less ridiculous 0.1 seconds as of commit 34af3cf

@@ -101,73 +46,166 @@ class RoleCall:
def __init__(self, bot):
self.bot = bot
self.settings = dataIO.load_json(SETTINGS_PATH)
self.reaction_queue = {}
self.reaction_user_queue = set()
self.queue_processor_task = bot.loop.create_task(self.queue_processor())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be nice and tidy, you might want to __unload this task as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implemented in commit 336c2f1

# chosen role board
try:
await self.post_role(entry)
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful with catch-all try/excepts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved with commit be67606

try:
await self.create_or_edit_role_channel(server, role_object, role_channel)
except Exception as e:
print(e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be careful with catch-all try/excepts.
also, to be nice to your users, you might want to use Red's logger instead of printing the exception directly to the console

settings = self.settings[server.id]
# retrieve channel mentions in the command message
channels = ctx.message.raw_channel_mentions
if len(channels) == 2:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and your raw_role_mentions has incorrect logic.
[p]rolecall add chan1 "test @role1 #chan2 #chan3" role2 :eyes: chan4
will cause the mentions in the message to be used instead of the role and channel in the actual argument

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied correct logic as of 47f7037

async def rolecall_add(self, ctx, channel: discord.Channel,
content_or_message_id: str, role: str,
emoji: str,
private_channel: str = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once we use this for awhile, let's come up with a simpler more memorable command signature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we definitely should 🤒


server_id = entry.server.id
roleboard_id = entry.roleboard_channel.id
message_id = entry.content_or_message_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sanity, you should probably add a separate attribute for message id in Entry which is either None or the message id and pull from that.

async def roleboard_channel(self, ctx, channel: discord.Channel=None):
"""Set the roleboard for this server.
@rolecall.command(pass_context=True, name="add", no_pm=True)
async def rolecall_add(self, ctx, channel: discord.Channel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anybody can use this command

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed with commit 2b9b585


@commands.group(pass_context=True, no_pm=True)
async def roleboard(self, ctx):
"""change roleboard settings"""
async def rolecall(self, ctx):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably add more entry management before we publish.
doesn't need to be in-depth.

@Chovin
Copy link
Contributor

Chovin commented Jan 25, 2018

@jasperdanan also noticed #48 and #47

@@ -52,7 +53,8 @@ def __init__(self, bot):

def _record_entry(self, entry: Entry):
""" record entry to settings file """

if type(entry.emoji) is discord.Emoji:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used isinstance as of 707ad4b

message_id = entry.content_or_message_id
keyring = self.settings[server_id][roleboard_id][message_id]
for emoji,role in keyring.items():
if entry.role.id == role['ROLE_ID']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you make sure 1 role can only have 1 entry?


# check if channel was mentioned
if private_channel is None:
pass
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do if private_channel is not None: do_things() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer it this way instead of using double negatives that may be mildly confusing to some people, or to me when I'm sleepy :3

@@ -333,7 +380,7 @@ def _get_object_by_name(self, otype, server, name, ignore_case=True):
""" returns object if it exists, otherwise create the object """
if object_type == "role": # for roles
role = discord.utils.get(server.roles, name=object_name)
try: # try in case role = None
try: # try in case role = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok?
please don't blindly commit ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what fixed the spamming problem for me. lol jk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed redundant indentation as of 37d82d4

role_object = discord.utils.get(server.roles, id=potential_role_id)
else:
role_object = await self.get_or_create("role", role, server)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whhhhhat?
you're getting or creating a role, but then if it already exists, you're deleting the role and then trying to get it again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Check if the passed argument contains a role id(AKA a role mention) and if it does, delete the role that was created earlier and just get the role associated with the id found

potential_role_id = nums_found[0]
if potential_role_id in [r.id for r in server.roles]:
role_object = discord.utils.get(server.roles, id=potential_role_id)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't return anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants