diff --git a/chatter/chat.py b/chatter/chat.py index 43c6ebe..327b8b4 100644 --- a/chatter/chat.py +++ b/chatter/chat.py @@ -91,7 +91,7 @@ class Chatter(Cog): for channel in ctx.guild.text_channels: if in_channel: channel = in_channel - await ctx.send("Gathering {}".format(channel.mention)) + await ctx.maybe_send_embed("Gathering {}".format(channel.mention)) user = None i = 0 send_time = after - timedelta(days=100) # Makes the first message a new message @@ -167,7 +167,7 @@ class Chatter(Cog): """ if not confirm: - await ctx.send( + await ctx.maybe_send_embed( "Warning, this command will erase all your training data and reset your configuration\n" "If you want to proceed, run the command again as `[p]chatter cleardata True`" ) @@ -242,7 +242,7 @@ class Chatter(Cog): Backup your training data to a json for later use """ - await ctx.send("Backing up data, this may take a while") + await ctx.maybe_send_embed("Backing up data, this may take a while") path: pathlib.Path = cog_data_path(self) @@ -253,9 +253,9 @@ class Chatter(Cog): ) if future: - await ctx.send(f"Backup successful! Look in {path} for your backup") + await ctx.maybe_send_embed(f"Backup successful! Look in {path} for your backup") else: - await ctx.send("Error occurred :(") + await ctx.maybe_send_embed("Error occurred :(") @chatter.command(name="trainenglish") async def chatter_train_english(self, ctx: commands.Context): @@ -266,9 +266,9 @@ class Chatter(Cog): future = await self.loop.run_in_executor(None, self._train_english) if future: - await ctx.send("Training successful!") + await ctx.maybe_send_embed("Training successful!") else: - await ctx.send("Error occurred :(") + await ctx.maybe_send_embed("Error occurred :(") @chatter.command() async def train(self, ctx: commands.Context, channel: discord.TextChannel): @@ -276,7 +276,7 @@ class Chatter(Cog): Trains the bot based on language in this guild """ - await ctx.send( + await ctx.maybe_send_embed( "Warning: The cog may use significant RAM or CPU if trained on large data sets.\n" "Additionally, large sets will use more disk space to save the trained data.\n\n" "If you experience issues, clear your trained data and train again on a smaller scope." @@ -286,10 +286,10 @@ class Chatter(Cog): conversation = await self._get_conversation(ctx, channel) if not conversation: - await ctx.send("Failed to gather training data") + await ctx.maybe_send_embed("Failed to gather training data") return - await ctx.send( + await ctx.maybe_send_embed( "Gather successful! Training begins now\n" "(**This will take a long time, be patient. See console for progress**)" ) @@ -304,9 +304,9 @@ class Chatter(Cog): pass if future: - await ctx.send("Training successful!") + await ctx.maybe_send_embed("Training successful!") else: - await ctx.send("Error occurred :(") + await ctx.maybe_send_embed("Error occurred :(") @commands.Cog.listener() async def on_message_without_command(self, message: discord.Message): diff --git a/coglint/coglint.py b/coglint/coglint.py index b867ef8..f1a58ee 100644 --- a/coglint/coglint.py +++ b/coglint/coglint.py @@ -35,7 +35,7 @@ class CogLint(Cog): self.do_lint = not curr await self.config.lint.set(not curr) - await ctx.send("Autolinting is now set to {}".format(not curr)) + await ctx.maybe_send_embed("Autolinting is now set to {}".format(not curr)) @commands.command() async def lint(self, ctx: commands.Context, *, code): @@ -44,7 +44,7 @@ class CogLint(Cog): Toggle autolinting with `[p]autolint` """ await self.lint_message(ctx.message) - await ctx.send("Hello World") + await ctx.maybe_send_embed("Hello World") async def lint_code(self, code): self.counter += 1 diff --git a/flag/flag.py b/flag/flag.py index b6d2673..4419e29 100644 --- a/flag/flag.py +++ b/flag/flag.py @@ -29,7 +29,7 @@ class Flag(Cog): """Clears all flags for all members in this server""" await self.config.guild(ctx.guild).flags.clear() - await ctx.send("Done") + await ctx.maybe_send_embed("Done") @checks.mod_or_permissions(manage_roles=True) @commands.guild_only() @@ -49,7 +49,7 @@ class Flag(Cog): Set the number of days for flags to expire after for server """ await self.config.guild(ctx.guild).days.set(days) - await ctx.send("Number of days for new flags to expire is now {} days".format(days)) + await ctx.maybe_send_embed("Number of days for new flags to expire is now {} days".format(days)) @flagset.command(name="dm") async def flagset_dm(self, ctx: commands.Context): @@ -58,7 +58,7 @@ class Flag(Cog): dm = await self.config.guild(ctx.guild).dm() await self.config.guild(ctx.guild).dm.set(not dm) - await ctx.send("DM-ing members when they get a flag is now set to **{}**".format(not dm)) + await ctx.maybe_send_embed("DM-ing members when they get a flag is now set to **{}**".format(not dm)) @staticmethod def _flag_template(): @@ -97,9 +97,9 @@ class Flag(Cog): try: await member.send(embed=outembed) except discord.Forbidden: - await ctx.send("DM-ing user failed") + await ctx.maybe_send_embed("DM-ing user failed") else: - await ctx.send("This member has no flags.. somehow..") + await ctx.maybe_send_embed("This member has no flags.. somehow..") @commands.guild_only() @checks.mod_or_permissions(manage_roles=True) @@ -111,7 +111,7 @@ class Flag(Cog): await self.config.guild(guild).flags.set_raw(str(member.id), value=[]) - await ctx.send("Success!") + await ctx.maybe_send_embed("Success!") @commands.guild_only() @commands.command(aliases=["flaglist"]) @@ -125,7 +125,7 @@ class Flag(Cog): if outembed: await ctx.send(embed=outembed) else: - await ctx.send("This member has no flags!") + await ctx.maybe_send_embed("This member has no flags!") @commands.guild_only() @commands.command(aliases=["flagall"]) diff --git a/hangman/hangman.py b/hangman/hangman.py index 4e44ce6..da6509f 100644 --- a/hangman/hangman.py +++ b/hangman/hangman.py @@ -154,19 +154,19 @@ class Hangman(Cog): theface = self.bot.get_emoji(int(theface.split(":")[2][:-1])) if theface is None: - await ctx.send("I could not find that emoji") + await ctx.maybe_send_embed("I could not find that emoji") return try: # Use the face as reaction to see if it's valid (THANKS FLAPJACK <3) await message.add_reaction(theface) except discord.errors.HTTPException: - await ctx.send("That's not an emoji I recognize.") + await ctx.maybe_send_embed("That's not an emoji I recognize.") return await self.config.guild(ctx.guild).theface.set(str(theface)) await self._update_hanglist() - await ctx.send("Face has been updated!") + await ctx.maybe_send_embed("Face has been updated!") @hangset.command() async def toggleemoji(self, ctx: commands.Context): @@ -174,26 +174,26 @@ class Hangman(Cog): current = await self.config.guild(ctx.guild).emojis() await self.config.guild(ctx.guild).emojis.set(not current) - await ctx.send("Emoji Letter reactions have been set to {}".format(not current)) + await ctx.maybe_send_embed("Emoji Letter reactions have been set to {}".format(not current)) @commands.command(aliases=["hang"]) async def hangman(self, ctx, guess: str = None): """Play a game of hangman against the bot!""" if guess is None: if self.the_data[ctx.guild]["running"]: - await ctx.send("Game of hangman is already running!\nEnter your guess!") + await ctx.maybe_send_embed("Game of hangman is already running!\nEnter your guess!") await self._printgame(ctx.channel) """await self.bot.send_cmd_help(ctx)""" else: - await ctx.send("Starting a game of hangman!") + await ctx.maybe_send_embed("Starting a game of hangman!") self._startgame(ctx.guild) await self._printgame(ctx.channel) elif not self.the_data[ctx.guild]["running"]: - await ctx.send("Game of hangman is not yet running!\nStarting a game of hangman!") + await ctx.maybe_send_embed("Game of hangman is not yet running!\nStarting a game of hangman!") self._startgame(ctx.guild) await self._printgame(ctx.channel) else: - await ctx.send("Guess by reacting to the message") + await ctx.maybe_send_embed("Guess by reacting to the message") # await self._guessletter(guess, ctx.channel) def _startgame(self, guild): diff --git a/leaver/leaver.py b/leaver/leaver.py index f6e7fd7..1147684 100644 --- a/leaver/leaver.py +++ b/leaver/leaver.py @@ -28,7 +28,7 @@ class Leaver(Cog): """Choose the channel to send leave messages to""" guild = ctx.guild await self.config.guild(guild).channel.set(ctx.channel.id) - await ctx.send("Channel set to " + ctx.channel.name) + await ctx.maybe_send_embed("Channel set to " + ctx.channel.name) @commands.Cog.listener() async def on_member_remove(self, member: discord.Member): diff --git a/lseen/lseen.py b/lseen/lseen.py index fe07c71..e4461b5 100644 --- a/lseen/lseen.py +++ b/lseen/lseen.py @@ -45,7 +45,7 @@ class LastSeen(Cog): enabled = not await self.config.guild(ctx.guild).enabled() await self.config.guild(ctx.guild).enabled.set(enabled) - await ctx.send( + await ctx.maybe_send_embed( "Seen for this server is now {}".format("Enabled" if enabled else "Disabled") ) @@ -60,7 +60,7 @@ class LastSeen(Cog): else: last_seen = await self.config.member(member).seen() if last_seen is None: - await ctx.send(embed=discord.Embed(description="I've never seen this user")) + await ctx.maybe_send_embed(embed=discord.Embed(description="I've never seen this user")) return last_seen = self.get_date_time(last_seen) diff --git a/qrinvite/qrinvite.py b/qrinvite/qrinvite.py index 99563e8..4adcbe2 100644 --- a/qrinvite/qrinvite.py +++ b/qrinvite/qrinvite.py @@ -44,7 +44,7 @@ class QRInvite(Cog): invite = await ctx.channel.invites() invite = invite[0] except discord.Forbidden: - await ctx.send("No permission to get an invite, please provide one") + await ctx.maybe_send_embed("No permission to get an invite, please provide one") return invite = invite.code @@ -52,7 +52,7 @@ class QRInvite(Cog): image_url = str(ctx.guild.icon_url) if image_url == "": # Still - await ctx.send( + await ctx.maybe_send_embed( "Could not get an image, please provide one. *(`{}help qrinvite` for details)*".format( ctx.prefix ) @@ -73,12 +73,12 @@ class QRInvite(Cog): if extension == "webp": new_path = convert_webp_to_png(str(image_path)) elif extension == "gif": - await ctx.send("gif is not supported yet, stay tuned") + await ctx.maybe_send_embed("gif is not supported yet, stay tuned") return elif extension == "png": new_path = str(image_path) else: - await ctx.send(f"{extension} is not supported yet, stay tuned") + await ctx.maybe_send_embed(f"{extension} is not supported yet, stay tuned") return myqr.run( diff --git a/reactrestrict/reactrestrict.py b/reactrestrict/reactrestrict.py index d28be9e..396a7ae 100644 --- a/reactrestrict/reactrestrict.py +++ b/reactrestrict/reactrestrict.py @@ -209,7 +209,7 @@ class ReactRestrict(Cog): """ message = await self._get_message(ctx, message_id) if message is None: - await ctx.send("That message doesn't seem to exist.") + await ctx.maybe_send_embed("That message doesn't seem to exist.") return # try: @@ -228,7 +228,7 @@ class ReactRestrict(Cog): # noinspection PyTypeChecker await self.add_reactrestrict(message_id, role) - await ctx.send("Message|Role combo added.") + await ctx.maybe_send_embed("Message|Role combo added.") @reactrestrict.command() async def remove(self, ctx: commands.Context, message_id: int, role: discord.Role): diff --git a/stealemoji/stealemoji.py b/stealemoji/stealemoji.py index cbcbc72..8d05fd7 100644 --- a/stealemoji/stealemoji.py +++ b/stealemoji/stealemoji.py @@ -69,14 +69,14 @@ class StealEmoji(Cog): if not curr_setting: await self.config.notify.set(1) - await ctx.send("Bot owner will now be notified when an emoji is stolen") + await ctx.maybe_send_embed("Bot owner will now be notified when an emoji is stolen") elif curr_setting == 1: channel: discord.TextChannel = ctx.channel await self.config.notify.set(channel.id) - await ctx.send("This channel will now be notified when an emoji is stolen") + await ctx.maybe_send_embed("This channel will now be notified when an emoji is stolen") else: await self.config.notify.set(0) - await ctx.send("Notifications are now off") + await ctx.maybe_send_embed("Notifications are now off") @checks.is_owner() @stealemoji.command(name="collect") @@ -87,7 +87,7 @@ class StealEmoji(Cog): self.is_on = await self.config.on() - await ctx.send("Collection is now " + str(not curr_setting)) + await ctx.maybe_send_embed("Collection is now " + str(not curr_setting)) @checks.is_owner() @commands.guild_only() @@ -105,12 +105,12 @@ class StealEmoji(Cog): already_a_guildbank = ctx.guild.id in (await self.config.guildbanks()) if already_a_guildbank: - await ctx.send( + await ctx.maybe_send_embed( "This is already an emoji bank\n" "Are you sure you want to remove the current server from the emoji bank list? (y/n)" ) else: - await ctx.send( + await ctx.maybe_send_embed( "This will upload custom emojis to this server\n" "Are you sure you want to make the current server an emoji bank? (y/n)" ) @@ -118,7 +118,7 @@ class StealEmoji(Cog): msg = await self.bot.wait_for("message", check=check) if msg.content.upper() in ["N", "NO"]: - await ctx.send("Cancelled") + await ctx.maybe_send_embed("Cancelled") return async with self.config.guildbanks() as guildbanks: @@ -128,9 +128,9 @@ class StealEmoji(Cog): guildbanks.append(ctx.guild.id) if already_a_guildbank: - await ctx.send("This server has been removed from being an emoji bank") + await ctx.maybe_send_embed("This server has been removed from being an emoji bank") else: - await ctx.send("This server has been added to be an emoji bank") + await ctx.maybe_send_embed("This server has been added to be an emoji bank") @commands.Cog.listener() async def on_reaction_add(self, reaction: discord.Reaction, user: discord.User): diff --git a/werewolf/game.py b/werewolf/game.py index 9451034..a64ace1 100644 --- a/werewolf/game.py +++ b/werewolf/game.py @@ -97,7 +97,7 @@ class Game: await self.get_roles(ctx) if len(self.players) != len(self.roles): - await ctx.send("Player count does not match role count, cannot start\n" + await ctx.maybe_send_embed("Player count does not match role count, cannot start\n" "Currently **{} / {}**\n" "Use `{}ww code` to pick a new game" "".format(len(self.players), len(self.roles), ctx.prefix)) @@ -112,7 +112,7 @@ class Game: reason="(BOT) Werewolf game role") self.to_delete.add(self.game_role) except (discord.Forbidden, discord.HTTPException): - await ctx.send("Game role not configured and unable to generate one, cannot start") + await ctx.maybe_send_embed("Game role not configured and unable to generate one, cannot start") self.roles = [] return False try: