Skip to content

Commit

Permalink
Update dependencies (#2148)
Browse files Browse the repository at this point in the history
Core dependencies:
- discord.py: Rapptz/discord.py@00a659c6 -> Rapptz/discord.py@00a659c6
- multidict: 4.4.0 -> 4.4.2

[docs]
- pyparsing: 2.2.0 -> 2.2.1
- sphinx: 1.7.8 -> 1.7.9

[test]
- pytest: 3.7.4 -> 3.8.1

[style]
- toml: 0.9.4 -> 0.9.6

----

I've also replaced usages of `discord.utils.get(guild.roles, id=id)` with the new O(1) `guild.get_role(id)` method.

Signed-off-by: Toby <tobyharradine@gmail.com>
  • Loading branch information
Tobotimus committed Sep 25, 2018
1 parent f8558b9 commit b249738
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 110 deletions.
174 changes: 89 additions & 85 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dependency_links.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/Rapptz/discord.py/tarball/00a659c6526b2445162b52eaf970adbd22c6d35d#egg=discord.py-1.0.0a0
https://github.com/Rapptz/discord.py/tarball/77239e4f1588b7cf99ca54c36665ebfc4ad5bd57#egg=discord.py-1.0.0a0
8 changes: 3 additions & 5 deletions redbot/cogs/audio/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ async def emptydisconnect(self, ctx, seconds: int):
async def role(self, ctx, role_name: discord.Role):
"""Sets the role to use for DJ mode."""
await self.config.guild(ctx.guild).dj_role.set(role_name.id)
dj_role_id = await self.config.guild(ctx.guild).dj_role()
dj_role_obj = discord.utils.get(ctx.guild.roles, id=dj_role_id)
dj_role_obj = ctx.guild.get_role(await self.config.guild(ctx.guild).dj_role())
await self._embed_msg(ctx, "DJ role set to: {}.".format(dj_role_obj.name))

@audioset.command()
Expand Down Expand Up @@ -301,7 +300,7 @@ async def settings(self, ctx):
"""Show the current settings."""
data = await self.config.guild(ctx.guild).all()
global_data = await self.config.all()
dj_role_obj = discord.utils.get(ctx.guild.roles, id=data["dj_role"])
dj_role_obj = ctx.guild.get_role(data["dj_role"])
dj_enabled = data["dj_enabled"]
emptydc_enabled = data["emptydc_enabled"]
emptydc_timer = data["emptydc_timer"]
Expand Down Expand Up @@ -2028,8 +2027,7 @@ async def _is_alone(self, ctx, member):
return nonbots <= 1

async def _has_dj_role(self, ctx, member):
dj_role_id = await self.config.guild(ctx.guild).dj_role()
dj_role_obj = discord.utils.get(ctx.guild.roles, id=dj_role_id)
dj_role_obj = ctx.guild.get_role(await self.config.guild(ctx.guild).dj_role())
if dj_role_obj in ctx.guild.get_member(member.id).roles:
return True
else:
Expand Down
6 changes: 3 additions & 3 deletions redbot/cogs/general/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ async def serverinfo(self, ctx):
data = discord.Embed(description=created_at, colour=(await ctx.embed_colour()))
data.add_field(name=_("Region"), value=str(guild.region))
data.add_field(name=_("Users"), value="{}/{}".format(online, total_users))
data.add_field(name=_("Text Channels"), value=text_channels)
data.add_field(name=_("Voice Channels"), value=voice_channels)
data.add_field(name=_("Roles"), value=len(guild.roles))
data.add_field(name=_("Text Channels"), value=str(text_channels))
data.add_field(name=_("Voice Channels"), value=str(voice_channels))
data.add_field(name=_("Roles"), value=str(len(guild.roles)))
data.add_field(name=_("Owner"), value=str(guild.owner))
data.set_footer(text=_("Server ID: ") + str(guild.id))

Expand Down
6 changes: 3 additions & 3 deletions redbot/cogs/mod/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async def pred(ctx: commands.Context):
# Author is bot owner or guild owner
return True

admin_role = discord.utils.get(guild.roles, id=await ctx.bot.db.guild(guild).admin_role())
mod_role = discord.utils.get(guild.roles, id=await ctx.bot.db.guild(guild).mod_role())
admin_role = guild.get_role(await ctx.bot.db.guild(guild).admin_role())
mod_role = guild.get_role(await ctx.bot.db.guild(guild).mod_role())

if admin_role in author.roles or mod_role in author.roles:
return True
Expand All @@ -35,7 +35,7 @@ async def pred(ctx: commands.Context):
guild = ctx.guild
if await ctx.bot.is_owner(author) or guild.owner == author:
return True
admin_role = discord.utils.get(guild.roles, id=await ctx.bot.db.guild(guild).admin_role())
admin_role = guild.get_role(await ctx.bot.db.guild(guild).admin_role())
if admin_role in author.roles:
return True
for vc in guild.voice_channels:
Expand Down
6 changes: 2 additions & 4 deletions redbot/cogs/reports/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ async def internal_filter(self, m: discord.Member, mod=False, perms=None):
ret = False
if mod:
guild = m.guild
admin_role = discord.utils.get(
guild.roles, id=await self.bot.db.guild(guild).admin_role()
)
mod_role = discord.utils.get(guild.roles, id=await self.bot.db.guild(guild).mod_role())
admin_role = guild.get_role(await self.bot.db.guild(guild).admin_role())
mod_role = guild.get_role(await self.bot.db.guild(guild).mod_role())
ret |= any(r in m.roles for r in (mod_role, admin_role))
if perms:
ret |= m.guild_permissions >= perms
Expand Down
11 changes: 7 additions & 4 deletions redbot/core/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,13 @@ async def _set(self, ctx):
"""Changes Red's settings"""
if ctx.invoked_subcommand is None:
if ctx.guild:
admin_role_id = await ctx.bot.db.guild(ctx.guild).admin_role()
admin_role = discord.utils.get(ctx.guild.roles, id=admin_role_id) or "Not set"
mod_role_id = await ctx.bot.db.guild(ctx.guild).mod_role()
mod_role = discord.utils.get(ctx.guild.roles, id=mod_role_id) or "Not set"
guild = ctx.guild
admin_role = (
guild.get_role(await ctx.bot.db.guild(ctx.guild).admin_role()) or "Not set"
)
mod_role = (
guild.get_role(await ctx.bot.db.guild(ctx.guild).mod_role()) or "Not set"
)
prefixes = await ctx.bot.db.guild(ctx.guild).prefix()
guild_settings = f"Admin role: {admin_role}\nMod role: {mod_role}\n"
else:
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"fuzzywuzzy==0.17.0",
"idna-ssl==1.1.0",
"idna==2.7",
"multidict==4.4.0",
"multidict==4.4.2",
"python-levenshtein==0.12.0",
"pyyaml==3.13",
"raven==6.9.0",
Expand Down Expand Up @@ -107,7 +107,7 @@ def get_version():
"more-itertools==4.3.0",
"pluggy==0.7.1",
"py==1.6.0",
"pytest==3.7.4",
"pytest==3.8.1",
"pytest-asyncio==0.9.0",
"six==1.11.0",
],
Expand All @@ -121,20 +121,20 @@ def get_version():
"Jinja2==2.10",
"MarkupSafe==1.0",
"packaging==17.1",
"pyparsing==2.2.0",
"pyparsing==2.2.1",
"six==1.11.0",
"Pygments==2.2.0",
"pytz==2018.5",
"requests==2.19.1",
"urllib3==1.23",
"six==1.11.0",
"snowballstemmer==1.2.1",
"sphinx==1.7.8",
"sphinx==1.7.9",
"sphinx_rtd_theme==0.4.1",
"sphinxcontrib-asyncio==0.2.0",
"sphinxcontrib-websupport==1.1.0",
],
"voice": ["red-lavalink==0.1.2"],
"style": ["black==18.6b4", "click==6.7", "toml==0.9.4"],
"style": ["black==18.6b4", "click==6.7", "toml==0.9.6"],
},
)

0 comments on commit b249738

Please sign in to comment.