mirror of
https://github.com/brandons209/Red-bot-Cogs.git
synced 2024-06-02 18:45:17 +12:00
black
This commit is contained in:
parent
566530db81
commit
09a7c6bbe0
|
@ -7,16 +7,12 @@ from redbot.core.utils.chat_formatting import pagify
|
||||||
class SmartReact(commands.Cog):
|
class SmartReact(commands.Cog):
|
||||||
"""Create automatic reactions when trigger words are typed in chat"""
|
"""Create automatic reactions when trigger words are typed in chat"""
|
||||||
|
|
||||||
default_guild_settings = {
|
default_guild_settings = {"reactions": {}}
|
||||||
"reactions": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.conf = Config.get_conf(self, identifier=964952632)
|
self.conf = Config.get_conf(self, identifier=964952632)
|
||||||
self.conf.register_guild(
|
self.conf.register_guild(**self.default_guild_settings)
|
||||||
**self.default_guild_settings
|
|
||||||
)
|
|
||||||
|
|
||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
@ -43,7 +39,7 @@ class SmartReact(commands.Cog):
|
||||||
return emoji
|
return emoji
|
||||||
for guild in self.bot.guilds:
|
for guild in self.bot.guilds:
|
||||||
for e in guild.emojis:
|
for e in guild.emojis:
|
||||||
if str(e.id) == emoji.split(':')[2][:-1]:
|
if str(e.id) == emoji.split(":")[2][:-1]:
|
||||||
return e
|
return e
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -77,8 +73,7 @@ class SmartReact(commands.Cog):
|
||||||
await message.channel.send("Successfully added this reaction.")
|
await message.channel.send("Successfully added this reaction.")
|
||||||
|
|
||||||
except (discord.errors.HTTPException, discord.errors.InvalidArgument):
|
except (discord.errors.HTTPException, discord.errors.InvalidArgument):
|
||||||
await message.channel.send("That's not an emoji I recognize. "
|
await message.channel.send("That's not an emoji I recognize. " "(might be custom!)")
|
||||||
"(might be custom!)")
|
|
||||||
|
|
||||||
async def remove_smart_reaction(self, guild, word, emoji, message):
|
async def remove_smart_reaction(self, guild, word, emoji, message):
|
||||||
try:
|
try:
|
||||||
|
@ -92,15 +87,12 @@ class SmartReact(commands.Cog):
|
||||||
await self.conf.guild(guild).reactions.set(reactions)
|
await self.conf.guild(guild).reactions.set(reactions)
|
||||||
await message.channel.send("Removed this smart reaction.")
|
await message.channel.send("Removed this smart reaction.")
|
||||||
else:
|
else:
|
||||||
await message.channel.send("That emoji is not used as a reaction "
|
await message.channel.send("That emoji is not used as a reaction " "for that word.")
|
||||||
"for that word.")
|
|
||||||
else:
|
else:
|
||||||
await message.channel.send("There are no smart reactions which use "
|
await message.channel.send("There are no smart reactions which use " "this emoji.")
|
||||||
"this emoji.")
|
|
||||||
|
|
||||||
except (discord.errors.HTTPException, discord.errors.InvalidArgument):
|
except (discord.errors.HTTPException, discord.errors.InvalidArgument):
|
||||||
await message.channel.send("That's not an emoji I recognize. "
|
await message.channel.send("That's not an emoji I recognize. " "(might be custom!)")
|
||||||
"(might be custom!)")
|
|
||||||
|
|
||||||
# Thanks irdumb#1229 for the help making this "more Pythonic"
|
# Thanks irdumb#1229 for the help making this "more Pythonic"
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
|
|
Loading…
Reference in a new issue