Merge pull request #174 from sourcery-ai-bot/master

Sourcery Starbot  refactored bobloy/Fox-V3
flag_develop
bobloy 4 years ago committed by GitHub
commit 95931d24f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,7 +54,6 @@ class AnnounceDaily(Cog):
Do `[p]help annd <subcommand>` for more details Do `[p]help annd <subcommand>` for more details
""" """
if ctx.invoked_subcommand is None:
pass pass
@commands.command() @commands.command()

@ -168,7 +168,7 @@ class AudioTrivia(Trivia):
@commands.guild_only() @commands.guild_only()
async def audiotrivia_list(self, ctx: commands.Context): async def audiotrivia_list(self, ctx: commands.Context):
"""List available trivia including audio categories.""" """List available trivia including audio categories."""
lists = set(p.stem for p in self._all_audio_lists()) lists = {p.stem for p in self._all_audio_lists()}
if await ctx.embed_requested(): if await ctx.embed_requested():
await ctx.send( await ctx.send(
embed=discord.Embed( embed=discord.Embed(

@ -48,7 +48,6 @@ class CCRole(commands.Cog):
"""Custom commands management with roles """Custom commands management with roles
Highly customizable custom commands with role management.""" Highly customizable custom commands with role management."""
if not ctx.invoked_subcommand:
pass pass
@ccrole.command(name="add") @ccrole.command(name="add")
@ -228,7 +227,7 @@ class CCRole(commands.Cog):
if not role_list: if not role_list:
return "None" return "None"
return ", ".join( return ", ".join(
[discord.utils.get(ctx.guild.roles, id=roleid).name for roleid in role_list] discord.utils.get(ctx.guild.roles, id=roleid).name for roleid in role_list
) )
embed.add_field(name="Text", value="```{}```".format(cmd["text"]), inline=False) embed.add_field(name="Text", value="```{}```".format(cmd["text"]), inline=False)
@ -252,7 +251,7 @@ class CCRole(commands.Cog):
) )
return return
cmd_list = ", ".join([ctx.prefix + c for c in sorted(cmd_list.keys())]) cmd_list = ", ".join(ctx.prefix + c for c in sorted(cmd_list.keys()))
cmd_list = "Custom commands:\n\n" + cmd_list cmd_list = "Custom commands:\n\n" + cmd_list
if ( if (
@ -325,9 +324,7 @@ class CCRole(commands.Cog):
async def eval_cc(self, cmd, message: discord.Message, ctx: commands.Context): async def eval_cc(self, cmd, message: discord.Message, ctx: commands.Context):
"""Does all the work""" """Does all the work"""
if cmd["proles"] and not ( if cmd["proles"] and not {role.id for role in message.author.roles} & set(cmd["proles"]):
set(role.id for role in message.author.roles) & set(cmd["proles"])
):
log.debug(f"{message.author} missing required role to execute {ctx.invoked_with}") log.debug(f"{message.author} missing required role to execute {ctx.invoked_with}")
return # Not authorized, do nothing return # Not authorized, do nothing

@ -196,7 +196,6 @@ class Chatter(Cog):
""" """
Base command for this cog. Check help for the commands list. Base command for this cog. Check help for the commands list.
""" """
if ctx.invoked_subcommand is None:
pass pass
@checks.admin() @checks.admin()

@ -58,11 +58,7 @@ class CogLint(Cog):
future = await self.bot.loop.run_in_executor(None, lint.py_run, path, "return_std=True") future = await self.bot.loop.run_in_executor(None, lint.py_run, path, "return_std=True")
if future: (pylint_stdout, pylint_stderr) = future or (None, None)
(pylint_stdout, pylint_stderr) = future
else:
(pylint_stdout, pylint_stderr) = None, None
# print(pylint_stderr) # print(pylint_stderr)
# print(pylint_stdout) # print(pylint_stdout)

@ -67,8 +67,7 @@ class Conquest(commands.Cog):
""" """
Base command for conquest cog. Start with `[p]conquest set map` to select a map. Base command for conquest cog. Start with `[p]conquest set map` to select a map.
""" """
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None and self.current_map is not None:
if self.current_map is not None:
await self._conquest_current(ctx) await self._conquest_current(ctx)
@conquest.command(name="list") @conquest.command(name="list")
@ -80,13 +79,12 @@ class Conquest(commands.Cog):
with maps_json.open() as maps: with maps_json.open() as maps:
maps_json = json.load(maps) maps_json = json.load(maps)
map_list = "\n".join(map_name for map_name in maps_json["maps"]) map_list = "\n".join(maps_json["maps"])
await ctx.maybe_send_embed(f"Current maps:\n{map_list}") await ctx.maybe_send_embed(f"Current maps:\n{map_list}")
@conquest.group(name="set") @conquest.group(name="set")
async def conquest_set(self, ctx: commands.Context): async def conquest_set(self, ctx: commands.Context):
"""Base command for admin actions like selecting a map""" """Base command for admin actions like selecting a map"""
if ctx.invoked_subcommand is None:
pass pass
@conquest_set.command(name="resetzoom") @conquest_set.command(name="resetzoom")

@ -30,7 +30,6 @@ class MapMaker(commands.Cog):
""" """
Base command for managing current maps or creating new ones Base command for managing current maps or creating new ones
""" """
if ctx.invoked_subcommand is None:
pass pass
@mapmaker.command(name="upload") @mapmaker.command(name="upload")

@ -65,7 +65,7 @@ def floodfill(image, xy, value, border=None, thresh=0) -> set:
if border is None: if border is None:
fill = _color_diff(p, background) <= thresh fill = _color_diff(p, background) <= thresh
else: else:
fill = p != value and p != border fill = p not in [value, border]
if fill: if fill:
pixel[s, t] = value pixel[s, t] = value
new_edge.add((s, t)) new_edge.add((s, t))

@ -27,7 +27,6 @@ class ExclusiveRole(Cog):
async def exclusive(self, ctx): async def exclusive(self, ctx):
"""Base command for managing exclusive roles""" """Base command for managing exclusive roles"""
if not ctx.invoked_subcommand:
pass pass
@exclusive.command(name="add") @exclusive.command(name="add")
@ -85,7 +84,7 @@ class ExclusiveRole(Cog):
if role_set is None: if role_set is None:
role_set = set(await self.config.guild(member.guild).role_list()) role_set = set(await self.config.guild(member.guild).role_list())
member_set = set([role.id for role in member.roles]) member_set = {role.id for role in member.roles}
to_remove = (member_set - role_set) - {member.guild.default_role.id} to_remove = (member_set - role_set) - {member.guild.default_role.id}
if to_remove and member_set & role_set: if to_remove and member_set & role_set:
@ -103,7 +102,7 @@ class ExclusiveRole(Cog):
await asyncio.sleep(1) await asyncio.sleep(1)
role_set = set(await self.config.guild(after.guild).role_list()) role_set = set(await self.config.guild(after.guild).role_list())
member_set = set([role.id for role in after.roles]) member_set = {role.id for role in after.roles}
if role_set & member_set: if role_set & member_set:
try: try:

@ -68,10 +68,7 @@ class CapturePrint:
self.string = None self.string = None
def write(self, string): def write(self, string):
if self.string is None: self.string = string if self.string is None else self.string + "\n" + string
self.string = string
else:
self.string = self.string + "\n" + string
class FIFO(commands.Cog): class FIFO(commands.Cog):
@ -230,7 +227,6 @@ class FIFO(commands.Cog):
""" """
Base command for handling scheduling of tasks Base command for handling scheduling of tasks
""" """
if ctx.invoked_subcommand is None:
pass pass
@fifo.command(name="wakeup") @fifo.command(name="wakeup")
@ -522,7 +518,6 @@ class FIFO(commands.Cog):
""" """
Add a new trigger for a task from the current guild. Add a new trigger for a task from the current guild.
""" """
if ctx.invoked_subcommand is None:
pass pass
@fifo_trigger.command(name="interval") @fifo_trigger.command(name="interval")

@ -55,7 +55,6 @@ class Flag(Cog):
""" """
Commands for managing Flag settings Commands for managing Flag settings
""" """
if ctx.invoked_subcommand is None:
pass pass
@flagset.command(name="expire") @flagset.command(name="expire")

@ -147,7 +147,6 @@ class Hangman(Cog):
@checks.mod_or_permissions(administrator=True) @checks.mod_or_permissions(administrator=True)
async def hangset(self, ctx): async def hangset(self, ctx):
"""Adjust hangman settings""" """Adjust hangman settings"""
if ctx.invoked_subcommand is None:
pass pass
@hangset.command() @hangset.command()
@ -250,7 +249,7 @@ class Hangman(Cog):
self.winbool[guild] = True self.winbool[guild] = True
for i in self.the_data[guild]["answer"]: for i in self.the_data[guild]["answer"]:
if i == " " or i == "-": if i in [" ", "-"]:
out_str += i * 2 out_str += i * 2
elif i in self.the_data[guild]["guesses"] or i not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": elif i in self.the_data[guild]["guesses"] or i not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
out_str += "__" + i + "__ " out_str += "__" + i + "__ "
@ -262,9 +261,7 @@ class Hangman(Cog):
def _guesslist(self, guild): def _guesslist(self, guild):
"""Returns the current letter list""" """Returns the current letter list"""
out_str = "" out_str = "".join(str(i) + "," for i in self.the_data[guild]["guesses"])
for i in self.the_data[guild]["guesses"]:
out_str += str(i) + ","
out_str = out_str[:-1] out_str = out_str[:-1]
return out_str return out_str

@ -65,9 +65,9 @@ class InfoChannel(Cog):
"offline": "Offline: {count}", "offline": "Offline: {count}",
} }
default_channel_ids = {k: None for k in self.default_channel_names.keys()} default_channel_ids = {k: None for k in self.default_channel_names}
# Only members is enabled by default # Only members is enabled by default
default_enabled_counts = {k: k == "members" for k in self.default_channel_names.keys()} default_enabled_counts = {k: k == "members" for k in self.default_channel_names}
default_guild = { default_guild = {
"category_id": None, "category_id": None,
@ -159,7 +159,6 @@ class InfoChannel(Cog):
""" """
Toggle different types of infochannels Toggle different types of infochannels
""" """
if not ctx.invoked_subcommand:
pass pass
@infochannelset.command(name="togglechannel") @infochannelset.command(name="togglechannel")

@ -36,58 +36,6 @@ class LaunchLib(commands.Cog):
async def _embed_launch_data(self, launch: ll.AsyncLaunch): async def _embed_launch_data(self, launch: ll.AsyncLaunch):
if False:
example_launch = ll.AsyncLaunch(
id="9279744e-46b2-4eca-adea-f1379672ec81",
name="Atlas LV-3A | Samos 2",
tbddate=False,
tbdtime=False,
status={"id": 3, "name": "Success"},
inhold=False,
windowstart="1961-01-31 20:21:19+00:00",
windowend="1961-01-31 20:21:19+00:00",
net="1961-01-31 20:21:19+00:00",
info_urls=[],
vid_urls=[],
holdreason=None,
failreason=None,
probability=0,
hashtag=None,
agency=None,
changed=None,
pad=ll.Pad(
id=93,
name="Space Launch Complex 3W",
latitude=34.644,
longitude=-120.593,
map_url="http://maps.google.com/maps?q=34.644+N,+120.593+W",
retired=None,
total_launch_count=3,
agency_id=161,
wiki_url=None,
info_url=None,
location=ll.Location(
id=11,
name="Vandenberg AFB, CA, USA",
country_code="USA",
total_launch_count=83,
total_landing_count=3,
pads=None,
),
map_image="https://spacelaunchnow-prod-east.nyc3.digitaloceanspaces.com/media/launch_images/pad_93_20200803143225.jpg",
),
rocket=ll.Rocket(
id=2362,
name=None,
default_pads=None,
family=None,
wiki_url=None,
info_url=None,
image_url=None,
),
missions=None,
)
# status: ll.AsyncLaunchStatus = await launch.get_status() # status: ll.AsyncLaunchStatus = await launch.get_status()
status = launch.status status = launch.status
@ -102,11 +50,7 @@ class LaunchLib(commands.Cog):
if launch.pad: if launch.pad:
urls += [launch.pad.info_url, launch.pad.wiki_url] urls += [launch.pad.info_url, launch.pad.wiki_url]
if urls: url = next((url for url in urls if urls is not None), None) if urls else None
url = next((url for url in urls if urls is not None), None)
else:
url = None
color = discord.Color.green() if status["id"] in [1, 3] else discord.Color.red() color = discord.Color.green() if status["id"] in [1, 3] else discord.Color.red()
em = discord.Embed(title=title, description=description, url=url, color=color) em = discord.Embed(title=title, description=description, url=url, color=color)
@ -171,7 +115,6 @@ class LaunchLib(commands.Cog):
@commands.group() @commands.group()
async def launchlib(self, ctx: commands.Context): async def launchlib(self, ctx: commands.Context):
"""Base command for getting launches""" """Base command for getting launches"""
if ctx.invoked_subcommand is None:
pass pass
@launchlib.command() @launchlib.command()

@ -25,7 +25,6 @@ class Leaver(Cog):
@checks.mod_or_permissions(administrator=True) @checks.mod_or_permissions(administrator=True)
async def leaverset(self, ctx): async def leaverset(self, ctx):
"""Adjust leaver settings""" """Adjust leaver settings"""
if ctx.invoked_subcommand is None:
pass pass
@leaverset.command() @leaverset.command()
@ -57,5 +56,3 @@ class Leaver(Cog):
) )
else: else:
await channel.send(out) await channel.send(out)
else:
pass

@ -45,13 +45,11 @@ class LastSeen(Cog):
@staticmethod @staticmethod
def get_date_time(s): def get_date_time(s):
d = dateutil.parser.parse(s) return dateutil.parser.parse(s)
return d
@commands.group(aliases=["setlseen"], name="lseenset") @commands.group(aliases=["setlseen"], name="lseenset")
async def lset(self, ctx: commands.Context): async def lset(self, ctx: commands.Context):
"""Change settings for lseen""" """Change settings for lseen"""
if ctx.invoked_subcommand is None:
pass pass
@lset.command(name="toggle") @lset.command(name="toggle")

@ -111,7 +111,6 @@ async def _withdraw_points(gardener: Gardener, amount):
if (gardener.points - amount) < 0: if (gardener.points - amount) < 0:
return False return False
else:
gardener.points -= amount gardener.points -= amount
return True return True
@ -245,11 +244,9 @@ class PlantTycoon(commands.Cog):
await self._load_plants_products() await self._load_plants_products()
modifiers = sum( modifiers = sum(
[
self.products[product]["modifier"] self.products[product]["modifier"]
for product in gardener.products for product in gardener.products
if gardener.products[product] > 0 if gardener.products[product] > 0
]
) )
degradation = ( degradation = (
@ -290,17 +287,15 @@ class PlantTycoon(commands.Cog):
product = product.lower() product = product.lower()
product_category = product_category.lower() product_category = product_category.lower()
if product in self.products and self.products[product]["category"] == product_category: if product in self.products and self.products[product]["category"] == product_category:
if product in gardener.products: if product in gardener.products and gardener.products[product] > 0:
if gardener.products[product] > 0:
gardener.current["health"] += self.products[product]["health"] gardener.current["health"] += self.products[product]["health"]
gardener.products[product] -= 1 gardener.products[product] -= 1
if gardener.products[product] == 0: if gardener.products[product] == 0:
del gardener.products[product.lower()] del gardener.products[product.lower()]
if product_category == "water": if product_category == "fertilizer":
emoji = ":sweat_drops:"
elif product_category == "fertilizer":
emoji = ":poop:" emoji = ":poop:"
# elif product_category == "tool": elif product_category == "water":
emoji = ":sweat_drops:"
else: else:
emoji = ":scissors:" emoji = ":scissors:"
message = "Your plant got some health back! {}".format(emoji) message = "Your plant got some health back! {}".format(emoji)
@ -310,18 +305,13 @@ class PlantTycoon(commands.Cog):
damage_msg = "You used {} too many times!".format(product) damage_msg = "You used {} too many times!".format(product)
else: else:
damage_msg = "You gave too much of {}.".format(product) damage_msg = "You gave too much of {}.".format(product)
message = "{} Your plant lost some health. :wilted_rose:".format( message = "{} Your plant lost some health. :wilted_rose:".format(damage_msg)
damage_msg
)
gardener.points += self.defaults["points"]["add_health"] gardener.points += self.defaults["points"]["add_health"]
await gardener.save_gardener() await gardener.save_gardener()
else: elif product in gardener.products or product_category != "tool":
message = "You have no {}. Go buy some!".format(product) message = "You have no {}. Go buy some!".format(product)
else: else:
if product_category == "tool":
message = "You don't have a {}. Go buy one!".format(product) message = "You don't have a {}. Go buy one!".format(product)
else:
message = "You have no {}. Go buy some!".format(product)
else: else:
message = "Are you sure you are using {}?".format(product_category) message = "Are you sure you are using {}?".format(product_category)
@ -412,24 +402,18 @@ class PlantTycoon(commands.Cog):
gardener.current = plant gardener.current = plant
await gardener.save_gardener() await gardener.save_gardener()
em = discord.Embed(description=message, color=discord.Color.green())
else: else:
plant = gardener.current plant = gardener.current
message = "You're already growing {} **{}**, silly.".format( message = "You're already growing {} **{}**, silly.".format(
plant["article"], plant["name"] plant["article"], plant["name"]
) )
em = discord.Embed(description=message, color=discord.Color.green()) em = discord.Embed(description=message, color=discord.Color.green())
await ctx.send(embed=em) await ctx.send(embed=em)
@_gardening.command(name="profile") @_gardening.command(name="profile")
async def _profile(self, ctx: commands.Context, *, member: discord.Member = None): async def _profile(self, ctx: commands.Context, *, member: discord.Member = None):
"""Check your gardening profile.""" """Check your gardening profile."""
if member is not None: author = member if member is not None else ctx.author
author = member
else:
author = ctx.author
gardener = await self._gardener(author) gardener = await self._gardener(author)
try: try:
await self._apply_degradation(gardener) await self._apply_degradation(gardener)
@ -440,9 +424,7 @@ class PlantTycoon(commands.Cog):
avatar = author.avatar_url if author.avatar else author.default_avatar_url avatar = author.avatar_url if author.avatar else author.default_avatar_url
em.set_author(name="Gardening profile of {}".format(author.name), icon_url=avatar) em.set_author(name="Gardening profile of {}".format(author.name), icon_url=avatar)
em.add_field(name="**Thneeds**", value=str(gardener.points)) em.add_field(name="**Thneeds**", value=str(gardener.points))
if not gardener.current: if gardener.current:
em.add_field(name="**Currently growing**", value="None")
else:
em.set_thumbnail(url=gardener.current["image"]) em.set_thumbnail(url=gardener.current["image"])
em.add_field( em.add_field(
name="**Currently growing**", name="**Currently growing**",
@ -450,16 +432,15 @@ class PlantTycoon(commands.Cog):
gardener.current["name"], gardener.current["health"] gardener.current["name"], gardener.current["health"]
), ),
) )
else:
em.add_field(name="**Currently growing**", value="None")
if not gardener.badges: if not gardener.badges:
em.add_field(name="**Badges**", value="None") em.add_field(name="**Badges**", value="None")
else: else:
badges = "" badges = "".join("{}\n".format(badge.capitalize()) for badge in gardener.badges)
for badge in gardener.badges:
badges += "{}\n".format(badge.capitalize())
em.add_field(name="**Badges**", value=badges) em.add_field(name="**Badges**", value=badges)
if not gardener.products: if gardener.products:
em.add_field(name="**Products**", value="None")
else:
products = "" products = ""
for product_name, product_data in gardener.products.items(): for product_name, product_data in gardener.products.items():
if self.products[product_name] is None: if self.products[product_name] is None:
@ -470,6 +451,8 @@ class PlantTycoon(commands.Cog):
self.products[product_name]["modifier"], self.products[product_name]["modifier"],
) )
em.add_field(name="**Products**", value=products) em.add_field(name="**Products**", value=products)
else:
em.add_field(name="**Products**", value="None")
if gardener.current: if gardener.current:
degradation = await self._degradation(gardener) degradation = await self._degradation(gardener)
die_in = await _die_in(gardener, degradation) die_in = await _die_in(gardener, degradation)
@ -600,7 +583,6 @@ class PlantTycoon(commands.Cog):
self.products[pd]["category"], self.products[pd]["category"],
), ),
) )
await ctx.send(embed=em)
else: else:
if amount <= 0: if amount <= 0:
message = "Invalid amount! Must be greater than 1" message = "Invalid amount! Must be greater than 1"
@ -629,6 +611,7 @@ class PlantTycoon(commands.Cog):
else: else:
message = "I don't have this product." message = "I don't have this product."
em = discord.Embed(description=message, color=discord.Color.green()) em = discord.Embed(description=message, color=discord.Color.green())
await ctx.send(embed=em) await ctx.send(embed=em)
@_gardening.command(name="convert") @_gardening.command(name="convert")
@ -663,8 +646,7 @@ class PlantTycoon(commands.Cog):
else: else:
gardener.current = {} gardener.current = {}
message = "You successfully shovelled your plant out." message = "You successfully shovelled your plant out."
if gardener.points < 0: gardener.points = max(gardener.points, 0)
gardener.points = 0
await gardener.save_gardener() await gardener.save_gardener()
em = discord.Embed(description=message, color=discord.Color.dark_grey()) em = discord.Embed(description=message, color=discord.Color.dark_grey())
@ -681,12 +663,12 @@ class PlantTycoon(commands.Cog):
except discord.Forbidden: except discord.Forbidden:
# Couldn't DM the degradation # Couldn't DM the degradation
await ctx.send("ERROR\nYou blocked me, didn't you?") await ctx.send("ERROR\nYou blocked me, didn't you?")
product = "water"
product_category = "water"
if not gardener.current: if not gardener.current:
message = "You're currently not growing a plant." message = "You're currently not growing a plant."
await _send_message(channel, message) await _send_message(channel, message)
else: else:
product = "water"
product_category = "water"
await self._add_health(channel, gardener, product, product_category) await self._add_health(channel, gardener, product, product_category)
@commands.command(name="fertilize") @commands.command(name="fertilize")
@ -700,11 +682,11 @@ class PlantTycoon(commands.Cog):
await ctx.send("ERROR\nYou blocked me, didn't you?") await ctx.send("ERROR\nYou blocked me, didn't you?")
channel = ctx.channel channel = ctx.channel
product = fertilizer product = fertilizer
product_category = "fertilizer"
if not gardener.current: if not gardener.current:
message = "You're currently not growing a plant." message = "You're currently not growing a plant."
await _send_message(channel, message) await _send_message(channel, message)
else: else:
product_category = "fertilizer"
await self._add_health(channel, gardener, product, product_category) await self._add_health(channel, gardener, product, product_category)
@commands.command(name="prune") @commands.command(name="prune")
@ -717,12 +699,12 @@ class PlantTycoon(commands.Cog):
# Couldn't DM the degradation # Couldn't DM the degradation
await ctx.send("ERROR\nYou blocked me, didn't you?") await ctx.send("ERROR\nYou blocked me, didn't you?")
channel = ctx.channel channel = ctx.channel
product = "pruner"
product_category = "tool"
if not gardener.current: if not gardener.current:
message = "You're currently not growing a plant." message = "You're currently not growing a plant."
await _send_message(channel, message) await _send_message(channel, message)
else: else:
product = "pruner"
product_category = "tool"
await self._add_health(channel, gardener, product, product_category) await self._add_health(channel, gardener, product, product_category)
# async def check_degradation(self): # async def check_degradation(self):

@ -97,9 +97,7 @@ class ReactRestrict(Cog):
""" """
current_combos = await self.combo_list() current_combos = await self.combo_list()
to_keep = [ to_keep = [c for c in current_combos if c.message_id != message_id or c.role_id != role.id]
c for c in current_combos if not (c.message_id == message_id and c.role_id == role.id)
]
if to_keep != current_combos: if to_keep != current_combos:
await self.set_combo_list(to_keep) await self.set_combo_list(to_keep)
@ -210,7 +208,6 @@ class ReactRestrict(Cog):
""" """
Base command for this cog. Check help for the commands list. Base command for this cog. Check help for the commands list.
""" """
if ctx.invoked_subcommand is None:
pass pass
@reactrestrict.command() @reactrestrict.command()

@ -69,13 +69,12 @@ class RPSLS(Cog):
def get_emote(self, choice): def get_emote(self, choice):
if choice == "rock": if choice == "rock":
emote = ":moyai:" return ":moyai:"
elif choice == "spock": elif choice == "spock":
emote = ":vulcan:" return ":vulcan:"
elif choice == "paper": elif choice == "paper":
emote = ":page_facing_up:" return ":page_facing_up:"
elif choice in ["scissors", "lizard"]: elif choice in ["scissors", "lizard"]:
emote = ":{}:".format(choice) return ":{}:".format(choice)
else: else:
emote = None return None
return emote

@ -69,7 +69,6 @@ class StealEmoji(Cog):
""" """
Base command for this cog. Check help for the commands list. Base command for this cog. Check help for the commands list.
""" """
if ctx.invoked_subcommand is None:
pass pass
@checks.is_owner() @checks.is_owner()
@ -268,7 +267,9 @@ class StealEmoji(Cog):
break break
if guildbank is None: if guildbank is None:
if await self.config.autobank(): if not await self.config.autobank():
return
try: try:
guildbank: discord.Guild = await self.bot.create_guild( guildbank: discord.Guild = await self.bot.create_guild(
"StealEmoji Guildbank", code="S93bqTqKQ9rM" "StealEmoji Guildbank", code="S93bqTqKQ9rM"
@ -296,9 +297,6 @@ class StealEmoji(Cog):
await self.bot.send_to_owners(invite) await self.bot.send_to_owners(invite)
log.info(f"Guild created id {guildbank.id}. Invite: {invite}") log.info(f"Guild created id {guildbank.id}. Invite: {invite}")
else:
return
# Next, have I saved this emoji before (because uploaded emoji != orignal emoji) # Next, have I saved this emoji before (because uploaded emoji != orignal emoji)
if str(emoji.id) in await self.config.stolemoji(): if str(emoji.id) in await self.config.stolemoji():

@ -77,7 +77,6 @@ class Timerole(Cog):
@commands.guild_only() @commands.guild_only()
async def timerole(self, ctx): async def timerole(self, ctx):
"""Adjust timerole settings""" """Adjust timerole settings"""
if ctx.invoked_subcommand is None:
pass pass
@timerole.command() @timerole.command()
@ -201,7 +200,7 @@ class Timerole(Cog):
reapply = all_guilds[guild_id]["reapply"] reapply = all_guilds[guild_id]["reapply"]
role_dict = all_guilds[guild_id]["roles"] role_dict = all_guilds[guild_id]["roles"]
if not any(role_data for role_data in role_dict.values()): # No roles if not any(role_dict.values()): # No roles
log.debug(f"No roles are configured for guild: {guild}") log.debug(f"No roles are configured for guild: {guild}")
continue continue
@ -232,7 +231,7 @@ class Timerole(Cog):
log.debug(f"{member.display_name} - Not time to check again yet") log.debug(f"{member.display_name} - Not time to check again yet")
continue continue
member: discord.Member member: discord.Member
has_roles = set(r.id for r in member.roles) has_roles = {r.id for r in member.roles}
# Stop if they currently have or don't have the role, and mark had_role # Stop if they currently have or don't have the role, and mark had_role
if (int(role_id) in has_roles and not role_data["remove"]) or ( if (int(role_id) in has_roles and not role_data["remove"]) or (

@ -19,7 +19,6 @@ class Unicode(Cog):
@commands.group(name="unicode", pass_context=True) @commands.group(name="unicode", pass_context=True)
async def unicode(self, ctx): async def unicode(self, ctx):
"""Encode/Decode a Unicode character.""" """Encode/Decode a Unicode character."""
if ctx.invoked_subcommand is None:
pass pass
@unicode.command() @unicode.command()

@ -90,7 +90,7 @@ async def parse_code(code, game):
if len(built) < digits: if len(built) < digits:
built += c built += c
if built == "T" or built == "W" or built == "N": if built in ["T", "W", "N"]:
# Random Towns # Random Towns
category = built category = built
built = "" built = ""
@ -116,8 +116,6 @@ async def parse_code(code, game):
options = [role for role in ROLE_LIST if 10 + idx in role.category] options = [role for role in ROLE_LIST if 10 + idx in role.category]
elif category == "N": elif category == "N":
options = [role for role in ROLE_LIST if 20 + idx in role.category] options = [role for role in ROLE_LIST if 20 + idx in role.category]
pass
if not options: if not options:
raise IndexError("No Match Found") raise IndexError("No Match Found")
@ -130,11 +128,8 @@ async def parse_code(code, game):
async def encode(role_list, rand_roles): async def encode(role_list, rand_roles):
"""Convert role list to code""" """Convert role list to code"""
out_code = ""
digit_sort = sorted(role for role in role_list if role < 10) digit_sort = sorted(role for role in role_list if role < 10)
for role in digit_sort: out_code = "".join(str(role) for role in digit_sort)
out_code += str(role)
digit_sort = sorted(role for role in role_list if 10 <= role < 100) digit_sort = sorted(role for role in role_list if 10 <= role < 100)
if digit_sort: if digit_sort:

@ -526,9 +526,10 @@ class Game:
async def _notify(self, event_name, **kwargs): async def _notify(self, event_name, **kwargs):
for i in range(1, 7): # action guide 1-6 (0 is no action) for i in range(1, 7): # action guide 1-6 (0 is no action)
tasks = [] tasks = [
for event in self.listeners.get(event_name, {}).get(i, []): asyncio.create_task(event(**kwargs))
tasks.append(asyncio.create_task(event(**kwargs))) for event in self.listeners.get(event_name, {}).get(i, [])
]
# Run same-priority task simultaneously # Run same-priority task simultaneously
await asyncio.gather(*tasks) await asyncio.gather(*tasks)
@ -555,10 +556,7 @@ class Game:
async def generate_targets(self, channel, with_roles=False): async def generate_targets(self, channel, with_roles=False):
embed = discord.Embed(title="Remaining Players", description="[ID] - [Name]") embed = discord.Embed(title="Remaining Players", description="[ID] - [Name]")
for i, player in enumerate(self.players): for i, player in enumerate(self.players):
if player.alive: status = "" if player.alive else "*[Dead]*-"
status = ""
else:
status = "*[Dead]*-"
if with_roles or not player.alive: if with_roles or not player.alive:
embed.add_field( embed.add_field(
name=f"{i} - {status}{player.member.display_name}", name=f"{i} - {status}{player.member.display_name}",
@ -579,7 +577,7 @@ class Game:
if channel_id not in self.p_channels: if channel_id not in self.p_channels:
self.p_channels[channel_id] = self.default_secret_channel.copy() self.p_channels[channel_id] = self.default_secret_channel.copy()
for x in range(10): # Retry 10 times for _ in range(10): # Retry 10 times
try: try:
await asyncio.sleep(1) # This will have multiple calls await asyncio.sleep(1) # This will have multiple calls
self.p_channels[channel_id]["players"].append(role.player) self.p_channels[channel_id]["players"].append(role.player)
@ -706,9 +704,7 @@ class Game:
if not self.any_votes_remaining: if not self.any_votes_remaining:
await channel.send("Voting is not allowed right now") await channel.send("Voting is not allowed right now")
return return
elif channel.name in self.p_channels: elif channel.name not in self.p_channels:
pass
else:
# Not part of the game # Not part of the game
await channel.send("Cannot vote in this channel") await channel.send("Cannot vote in this channel")
return return
@ -757,14 +753,14 @@ class Game:
await self._at_voted(target) await self._at_voted(target)
async def eval_results(self, target, source=None, method=None): async def eval_results(self, target, source=None, method=None):
if method is not None: if method is None:
out = "**{ID}** - " + method
return out.format(ID=target.id, target=target.member.display_name)
else:
return "**{ID}** - {target} the {role} was found dead".format( return "**{ID}** - {target} the {role} was found dead".format(
ID=target.id, target=target.member.display_name, role=await target.role.get_role() ID=target.id, target=target.member.display_name, role=await target.role.get_role()
) )
out = "**{ID}** - " + method
return out.format(ID=target.id, target=target.member.display_name)
async def _quit(self, player): async def _quit(self, player):
""" """
Have player quit the game Have player quit the game

@ -75,7 +75,6 @@ class Werewolf(Cog):
""" """
Base command to adjust settings. Check help for command list. Base command to adjust settings. Check help for command list.
""" """
if ctx.invoked_subcommand is None:
pass pass
@commands.guild_only() @commands.guild_only()
@ -166,7 +165,6 @@ class Werewolf(Cog):
""" """
Base command for this cog. Check help for the commands list. Base command for this cog. Check help for the commands list.
""" """
if ctx.invoked_subcommand is None:
pass pass
@commands.guild_only() @commands.guild_only()
@ -348,7 +346,6 @@ class Werewolf(Cog):
""" """
Find custom roles by name, alignment, category, or ID Find custom roles by name, alignment, category, or ID
""" """
if ctx.invoked_subcommand is None or ctx.invoked_subcommand == self.ww_search:
pass pass
@ww_search.command(name="name") @ww_search.command(name="name")

Loading…
Cancel
Save