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
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
2a006d2
get_role_by_name and generalized exceptions for that and get_channel_…
Chovin Oct 9, 2017
5a726ed
Merge branch 'master' into roleboard
Chovin Oct 25, 2017
ee7e78a
made get_or_create method
gmcaguilar Nov 27, 2017
ea2bbbd
added UI Specification and appended missing await keyword for async f…
gmcaguilar Nov 27, 2017
08ffe37
removed redundant .lower() call
gmcaguilar Nov 28, 2017
3a77e99
Merge branch 'master' into roleboard
gmcaguilar Nov 28, 2017
6bab6b4
change loop in get_or_create to discord.utils.get
gmcaguilar Dec 2, 2017
c8ab930
fix indentation
gmcaguilar Dec 2, 2017
3c41795
add a try-except in case role is not found in the list
gmcaguilar Dec 2, 2017
d10669e
add try except blocks in case user has no privileges to create a role…
gmcaguilar Dec 2, 2017
f760ee4
add comments to get_or_create
gmcaguilar Dec 2, 2017
1803c2e
added create_channel functionality if channel specified does not exist
gmcaguilar Dec 2, 2017
aa0051e
added description for get_or_create method
gmcaguilar Dec 2, 2017
641d8b0
added reaction argument
gmcaguilar Dec 16, 2017
c92f6e3
fixed case-sensitive bug for channel names
gmcaguilar Dec 19, 2017
6328964
implemented check if the user is trying to create a channel or add a …
gmcaguilar Dec 20, 2017
cef629b
created make_entry function for constructing roleboard entries
gmcaguilar Dec 20, 2017
2ae8cc2
fix un-awaited coro function call
gmcaguilar Dec 20, 2017
ab35a95
made some changes on the expected UI
gmcaguilar Dec 21, 2017
3bb1914
transferred create channel feature to the 2nd channel argument
gmcaguilar Dec 26, 2017
369ee69
added .gitignore for sample screenshots
gmcaguilar Dec 26, 2017
2c70697
initial entries data structure draft
gmcaguilar Dec 27, 2017
fb08ef2
updated default JSON format
gmcaguilar Dec 27, 2017
aeb15b8
use raw_channel_mentions instead to account for repeated channel ment…
gmcaguilar Dec 28, 2017
256481d
use get_channel since raw_channel_mentions return a list of channel I…
gmcaguilar Dec 28, 2017
b02be32
updated description for add command
gmcaguilar Dec 28, 2017
ef29123
additional updates to add command description
gmcaguilar Dec 28, 2017
4e145ec
removed embed option and added feature that adds a role to an existin…
gmcaguilar Dec 30, 2017
fe9f92a
wrote post_role function
gmcaguilar Jan 2, 2018
a0b5088
no need to list the roles since it hinders freedom for message to be …
gmcaguilar Jan 3, 2018
ad1310d
removed debugging tests
gmcaguilar Jan 3, 2018
ccb29d3
modified post_role to get message object then post role reaction to it
gmcaguilar Jan 3, 2018
0ce6bb7
fixed consistency check because it was duplicating keys
gmcaguilar Jan 4, 2018
4c1af98
change function name to _record_entry
gmcaguilar Jan 4, 2018
c234f3d
updated description since it doesn't really "construct" anything
gmcaguilar Jan 4, 2018
e0b33c9
updated description again--simplified previous description
gmcaguilar Jan 4, 2018
5630ca0
updated descriptions again to be more accurate
gmcaguilar Jan 4, 2018
fd514cf
updated comments to reflect actual process
gmcaguilar Jan 4, 2018
a915104
updated structure of settings file
gmcaguilar Jan 4, 2018
9923a0b
wrote Entry class constructor
gmcaguilar Jan 4, 2018
d8685e6
make Entry object and pass it to _record_entry() instead
gmcaguilar Jan 4, 2018
c72bb83
save changes to file
gmcaguilar Jan 4, 2018
6b1c564
moved _save() to correct location(placed it incorrectly in the previo…
gmcaguilar Jan 4, 2018
ca7fc59
corrected variable name mismatch
gmcaguilar Jan 4, 2018
609a783
changed default settings structure
gmcaguilar Jan 5, 2018
9f5005d
modified _record_entry() caused by changed structure of settings file
gmcaguilar Jan 5, 2018
62b74b4
fixed incorrect dict key
gmcaguilar Jan 5, 2018
dab4a2f
forgot to include channel id with the keyring
gmcaguilar Jan 5, 2018
6ec53db
updated default structure of settings file
gmcaguilar Jan 5, 2018
63b3014
make role and reaction optional for Entry constructor
gmcaguilar Jan 5, 2018
6f9d741
simplified structure of settings file
gmcaguilar Jan 5, 2018
367008e
initial blueprint of on_socket_raw_receive
gmcaguilar Jan 5, 2018
8feb3d5
wrote _check_entry() which checks if passed entry exists in settings …
gmcaguilar Jan 5, 2018
878464b
check if reaction add entry exists in the settings file
gmcaguilar Jan 5, 2018
8203fc9
record role name too
gmcaguilar Jan 5, 2018
9043b15
changed settings structure since an entry can contain multiple roles
gmcaguilar Jan 5, 2018
f8f04c5
wrote _get_role_from_entry to retrieve a role from the settings file …
gmcaguilar Jan 5, 2018
73b0a50
completed on_socket_raw_receive tasks
gmcaguilar Jan 5, 2018
c1d1313
prevent bots from gaining roles so roles are not assigned to the bot …
gmcaguilar Jan 5, 2018
43e3392
fixed circular reference in _record_entry()
gmcaguilar Jan 6, 2018
3f05fab
changed shallow copy to deep copy since it overwrites previous record…
gmcaguilar Jan 6, 2018
8a7c32a
refined the description and the attribute names of an Entry object to…
gmcaguilar Jan 6, 2018
bce1fb5
entry object accepts content or message id now instead of message object
gmcaguilar Jan 6, 2018
f9fd841
an Entry object is now passed to post_entry() and post_role() to make…
gmcaguilar Jan 6, 2018
f35cdbb
updated _record_entry() because of changes made to the attributes of …
gmcaguilar Jan 6, 2018
266821e
assign message id to content_or_message_id after a post_entry instanc…
gmcaguilar Jan 6, 2018
bac7d53
pass entry object to post_role() and post_entry() since that's the on…
gmcaguilar Jan 6, 2018
1fb8f7d
pass message id instead since Entry does not accept message object an…
gmcaguilar Jan 6, 2018
eca8bb8
fixed functions that still contained references to old message object…
gmcaguilar Jan 6, 2018
52bf96b
fixed overlooked unmodified attribute assignments in the Entry constr…
gmcaguilar Jan 6, 2018
0fb5ea1
fixed another unchanged attribute assignment statement
gmcaguilar Jan 6, 2018
d8d1b76
fixed unchanged old attribute name references
gmcaguilar Jan 6, 2018
5f7fd10
fixed more unchanged Entry attribute references
gmcaguilar Jan 6, 2018
8122b8d
refined broleboard add description and option names. Also, rearranged…
gmcaguilar Jan 6, 2018
11411b7
added feature that unassigns role from user if he removes his reaction
gmcaguilar Jan 8, 2018
4edec6b
queued reaction events but spamming problem is not fixed yet. Also, f…
gmcaguilar Jan 10, 2018
a94ba3d
implemented random role color generator
gmcaguilar Jan 10, 2018
6eb51a5
implemented option to create a personal channel for the role
gmcaguilar Jan 11, 2018
f9f01ca
updated roleboard add description
gmcaguilar Jan 11, 2018
32a1ad9
added try-catch blocks for potential errors caused by passing in exis…
gmcaguilar Jan 11, 2018
6b8e922
added fix for spamming
gmcaguilar Jan 13, 2018
132cad3
modified to accept both unicode and custom emojis for flexibility
gmcaguilar Jan 13, 2018
dbf01c3
added functionality for providing both existing and non-existing role…
gmcaguilar Jan 13, 2018
065a7c4
cleaned up spacing and comments for readability and maintenance
gmcaguilar Jan 24, 2018
159cf7e
removed roleboard channel command
gmcaguilar Jan 24, 2018
dce5f35
delete outdated UI specification file
gmcaguilar Jan 24, 2018
2b04f76
updated descriptions of add command and create_or_edit_role_channel
gmcaguilar Jan 24, 2018
f9785fd
updated info.json
gmcaguilar Jan 24, 2018
6608e9f
changed "roleboard" to "rolecall" to avoid confusion for the users
gmcaguilar Jan 24, 2018
2b8c959
revamped the add command's argument names to be more intuitive. Also,…
gmcaguilar Jan 24, 2018
11a3c04
fixed unchanged "roleboard" keyword
gmcaguilar Jan 24, 2018
3323b97
updated description of add command to be more readable
gmcaguilar Jan 24, 2018
850d393
allow user to either mention the role or specify its name
gmcaguilar Jan 24, 2018
fadf7e9
applied fix for acceptance of both unicode and custom emojis #47
gmcaguilar Jan 25, 2018
707ad4b
used isinstance instead for type checking to allow support for parent…
gmcaguilar Jan 26, 2018
47f7037
applied fix for the case when roles or channels are mentioned in the …
gmcaguilar Jan 26, 2018
34af3cf
added fix for spam prevention issue by splitting up the reaction set #48
gmcaguilar Jan 28, 2018
56f59ed
added a duplicate role prevention feature to avoid linking the same r…
gmcaguilar Jan 28, 2018
5a676e1
created isduplicate() to check if emoji or role has been used in the …
gmcaguilar Jan 28, 2018
c670fcf
remove redundant .png ignore
gmcaguilar Jan 30, 2018
6d7ebd4
remove unused import of threading module
gmcaguilar Jan 30, 2018
37d82d4
fixed accidental comment indentation
gmcaguilar Jan 30, 2018
fb26927
fixed incorrect logic on role creation that could cause the role_obje…
gmcaguilar Jan 31, 2018
62a7e2c
added permission checking to avoid creation of entries that are non-f…
gmcaguilar Feb 8, 2018
336c2f1
created __unload method for cancelling looped task
gmcaguilar Feb 8, 2018
be67606
used specific Exception classes instead of catch-all exceptions to av…
gmcaguilar Feb 8, 2018
2b9b585
added check for mod status if command is invoked
gmcaguilar Feb 9, 2018
c11ed06
create a separate method for checking if a role was mentioned
gmcaguilar Mar 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
rolecall/**/*.png
9 changes: 4 additions & 5 deletions rolecall/rolecall.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
from copy import deepcopy
import json
import threading
from random import randint
import re

Expand Down Expand Up @@ -146,14 +145,14 @@ async def rolecall_add(self, ctx, channel: discord.Channel,
server = ctx.message.server
author = ctx.message.author

# check if role was mentioned
# check if role was mentioned
role_object = await self.get_or_create("role", role, server)
nums_found = re.findall('\d+', role)
if nums_found:
potential_role_id = nums_found[0]
if potential_role_id in [r.id for r in server.roles]:
await self.bot.delete_role(server, role_object)
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


# check if channel was mentioned
if private_channel is None:
Expand Down Expand Up @@ -380,7 +379,7 @@ async def get_or_create(self, object_type: str, object_name: str, server):
""" 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
if role.name == object_name:
return role
except Exception as e: # if it is None, create new role
Expand Down