diff --git a/basecontext.py b/basecontext.py index 972521a..94bc31b 100644 --- a/basecontext.py +++ b/basecontext.py @@ -1379,7 +1379,7 @@ async def handler(self, command, message): # Ensure the mentioned channel is in this guild, or else we don't accept it. if message.channel_mentions[0].guild != message.guild: await message.reply("I could not find " + message.channel_mentions[0].name + - " in this server.") + " in this server.", mention_author=False) return # Set the mentioned channel as the announcement channel channelid = message.channel_mentions[0].id @@ -1399,7 +1399,7 @@ async def handler(self, command, message): if not channel.permissions_for(channel.guild.me).send_messages: msg += "\nI **do not** have permission to send messages in that channel! Announcements will fail " \ "until permission is granted. " - await message.reply(msg) + await message.reply(msg, mention_author=False) return elif command[0] == 'stop': # Stop announcing - we set an override option named Stop to true @@ -1410,7 +1410,7 @@ async def handler(self, command, message): # Set the override. Announce checks for this before announcing mydata['COver'][message.guild.id]['Stop'] = True msg = "Ok, I will stop announcing on this server." - await message.reply(msg) + await message.reply(msg, mention_author=False) return elif command[0] == 'resume': # Unset the Stop override - nothing else needed. @@ -1423,7 +1423,7 @@ async def handler(self, command, message): msg = "I will resume announcements to " + channel.mention + "." else: msg = "No announcement channel has been set, please set one with listen." - await message.reply(msg) + await message.reply(msg, mention_author=False) return elif command[0] == 'option': # Moved to function await self.option(command, message) @@ -1451,20 +1451,20 @@ async def handler(self, command, message): if len(command) == 1: # No stream given msg += "\nYou must specify a stream name to show the detailed record for." if msg: - await message.reply(msg) + await message.reply(msg, mention_author=False) else: try: await self.detailannounce(command[1], message.guild.id) except ChannelNotSet: await message.reply( "You must specify an announcement channel via the channel command before calling " - "detailannounce") + "detailannounce", mention_author=False) return else: msg = "Unknown command: " + command[0] + ". Please follow the module name with a command, then with" \ " any parameters for the command. The available commands are: " + \ ", ".join(self.commandlist.keys()) + "." - await message.reply(msg) + await message.reply(msg, mention_author=False) return else: # No extra command given, or command was help. Unknown command is handled above now. # This is your help area, which should give your users an idea how to use @@ -1491,7 +1491,7 @@ async def handler(self, command, message): msg += "\nThe adult options CAN NOT 100% shield your users from adult content. Forgetful " \ "streamers, API errors, bugs in the module, and old adult previews cached by the " \ "streaming site/discord/etc. may allow adult content through." - await message.reply(msg) + await message.reply(msg, mention_author=False) # The general help goes here - it should list commands or some site that # has a list of them else: @@ -1519,7 +1519,7 @@ async def handler(self, command, message): msg += "\n**The last attempt to update the API failed!** The API may be down. This will cause " \ "certain commands to not work properly. Announcements will resume normally once the API " \ "is connectable." - await message.reply(msg) + await message.reply(msg, mention_author=False) return async def add(self, command, message): @@ -1543,7 +1543,7 @@ async def add(self, command, message): if message.channel_mentions: # Channel mention, so make an override if message.channel_mentions[0].guild != message.guild: await message.reply("I could not find " + message.channel_mentions[0].name + - " in this server.") + " in this server.", mention_author=False) return if 'COver' not in mydata: # We need to make the section mydata['COver'] = {} # New dict @@ -1628,7 +1628,7 @@ async def add(self, command, message): channel = await self.resolvechannel(message.guild.id) if not channel: msg += "\nYou must set an announcement channel via the channel command before announcements will work!" - await message.reply(msg) + await message.reply(msg, mention_author=False) return async def list(self, command, message): @@ -1686,7 +1686,7 @@ async def list(self, command, message): msg += "\n**Last " + str(self.lastupdate.failed) + " attempt(s) to update API failed.**" if await self.getoption(message.guild.id, 'Stop'): msg += "\nMessages are currently stopped via the stop command." - await message.reply(msg) + await message.reply(msg, mention_author=False) async def option(self, command, message): """Sets or clears one or more options for the server. @@ -1696,7 +1696,7 @@ async def option(self, command, message): """ if len(command) == 1: msg = "No option provided. Please use the help menu for info on how to use the option command." - await message.reply(msg) + await message.reply(msg, mention_author=False) return msg = "" setopt = set() @@ -1727,7 +1727,7 @@ async def option(self, command, message): msg += "Options set: " + ", ".join(setopt) + ". " if unknown: msg += "One or more unknown options found. Please check the help menu for available options." - await message.reply(msg) + await message.reply(msg, mention_author=False) async def streamoption(self, command, message): """Sets or clears one or more options for a single watched stream in the server. If no options are given, it @@ -1740,7 +1740,7 @@ async def streamoption(self, command, message): if len(command) < 2: msg = "Command requires a stream name, or a stream name and option(s). Please use the help menu " \ "for info on how to use the streamoption command. " - await message.reply(msg) + await message.reply(msg, mention_author=False) return # If we're not listening to it right now, don't set the override. # This avoids mismatched capitalization from the user setting the @@ -1750,7 +1750,7 @@ async def streamoption(self, command, message): and record in mydata["Servers"][message.guild.id]["Listens"]): msg = record + "is not in your list of watched streams. Check spelling and capitalization and " \ "try again. " - await message.reply(msg) + await message.reply(msg, mention_author=False) return if len(command) == 2: # No options given, just show current options msg = "No overrides exist for the given stream; all options will default to the server wide settings." @@ -1768,7 +1768,7 @@ async def streamoption(self, command, message): msg = "The following overrides are set (Option: Setting) :\n" + msg except KeyError: pass - await message.reply(msg) + await message.reply(msg, mention_author=False) return msg = "" setopt = set() @@ -1814,7 +1814,7 @@ async def streamoption(self, command, message): msg += "Options set: " + ", ".join(setopt) + ". " if unknown: msg += "One or more unknown options found. Please check the help menu for available options." - await message.reply(msg) + await message.reply(msg, mention_author=False) async def remove(self, command, message): """Removes streams from the list of watched streams for a guild. @@ -1825,11 +1825,11 @@ async def remove(self, command, message): mydata = self.mydata if not (message.guild.id in mydata["Servers"]): # Haven't created servers info dict yet - await message.reply("No streams are being listened to yet!") + await message.reply("No streams are being listened to yet!", mention_author=False) return if not ("Listens" in mydata["Servers"][message.guild.id]): # No listens added yet - await message.reply("No streams are being listened to yet!") + await message.reply("No streams are being listened to yet!", mention_author=False) return added = set() msg = "" @@ -1881,7 +1881,7 @@ async def remove(self, command, message): msg += "\nThe following streams were not found and could not be removed: " + ", ".join(notfound) if not msg: msg += "Unable to remove any streams due to unknown error." - await message.reply(msg) + await message.reply(msg, mention_author=False) async def announceall(self, command, message): """Gives announcements for any online streams missing them. Usually due to the bot being offline when the stream @@ -1896,7 +1896,7 @@ async def announceall(self, command, message): # Iterate over all this servers' listens if not (message.guild.id in mydata["Servers"] and "Listens" in mydata["Servers"][message.guild.id]): - await message.reply("Server is not listening to any streams!") + await message.reply("Server is not listening to any streams!", mention_author=False) return for item in mydata["Servers"][message.guild.id]["Listens"]: # Iterate over servers watched streams if item in self.parsed: # Stream is online @@ -1918,4 +1918,4 @@ async def announceall(self, command, message): msg += "\n**The last attempt to update API failed.** The API may be down. This will cause delays " \ "in announcing streams. Streams will be announced/edited/removed as needed when the API " \ "call succeeds. " - await message.reply(msg) + await message.reply(msg, mention_author=False) diff --git a/dbcontext.py b/dbcontext.py index dced5ae..7ad673b 100644 --- a/dbcontext.py +++ b/dbcontext.py @@ -464,7 +464,7 @@ async def helphandler(command, message): msg += "\nNote that the link includes the permissions that I will be granted when joined.\n" msg += "\nThe current link is: <" + invite + ">" msg += "\nIf the bot is already in your server, re-inviting will NOT change the current permissions." - await message.reply(msg) + await message.reply(msg, mention_author=False) return elif command[0] in contfuncs: # User asking for help with a context. # Redirect the command to the given module. @@ -479,7 +479,7 @@ async def helphandler(command, message): msg += "\nThe following modules are available for use: " + ", ".join(contexts) msg += "\nI listen to commands on any channel from users with the Manage Server permission." msg += " Additionally, I will listen to commands from users with a role named " + str(managerolename) - await message.reply(msg) + await message.reply(msg, mention_author=False) return @@ -675,12 +675,12 @@ async def managehandler(command, message): msg += "\n**Bot does not** have permission to manage user roles. Only help, check, notifyoff, and perms " \ "commands will work. " msg += "\nPlease manually add the 'manage roles' permission to make use of additional features." - await message.reply(msg) + await message.reply(msg, mention_author=False) return validcommands = ('help', 'check', 'add', 'remove', 'setupchan', 'notifyon', 'notifyoff', 'perms') if not command[0] in validcommands: await message.reply("Please provide one of the following commands: " + - ",".join(validcommands)) + ",".join(validcommands), mention_author=False) return # We check what permissions are missing and inform the user why we need them if command[0] == 'perms': @@ -739,12 +739,12 @@ async def managehandler(command, message): msg += "\nMissing 'Send Messages' perm for #" + message.channel.name + \ ". This permission is needed to send messages to the channel. " # So instead of responding in channel, we PM it to the user - await message.reply(msg) + await message.reply(msg, mention_author=False) return # And return so we don't try to send it twice if msg: # We had at least one permission missing - await message.reply(msg) + await message.reply(msg, mention_author=False) else: - await message.reply("Bot has no missing permissions.") + await message.reply("Bot has no missing permissions.", mention_author=False) return if command[0] == 'check': hasperm = set() @@ -775,7 +775,7 @@ async def managehandler(command, message): if not msg: # Should never happen, but maybe no user names were provided. msg += "Unable to check any users due to unknown error. Please ensure you provided a list of usernames " \ "with discriminator to check. " - await message.reply(msg) + await message.reply(msg, mention_author=False) return mydata = contexts['manage']['Data'] # Keep a reference to our module data # notify off is the only one of these that DOESNT require permissions. @@ -800,14 +800,15 @@ async def managehandler(command, message): msg += " I have also attempted to unpin the old reaction message." else: msg += " The old reaction message is no longer needed and can be unpinned." - await message.reply(msg) + await message.reply(msg, mention_author=False) return - await message.reply("Notifications are currently off for this server.") + await message.reply("Notifications are currently off for this server.", mention_author=False) return # See if we have permission to add/remove user roles. If not, say so if not message.channel.permissions_for(message.guild.me).manage_roles: await message.reply( - "Bot does not have permission to manage user roles, requested command can not be completed without it.") + "Bot does not have permission to manage user roles, requested command can not be completed without it.", + mention_author=False) return # We can't do any of the following things without it, so quit if command[0] == 'notifyon': # Step 1 - Find/Create the role @@ -817,12 +818,14 @@ async def managehandler(command, message): if not notifyrole: # We couldn't find or make the role. We already checked for permissions, so this shouldn't happen, but JIC await message.reply( - "Unable to create/find the necessary role. Please ensure the bot has the manage_roles permission.") + "Unable to create/find the necessary role. Please ensure the bot has the manage_roles permission.", + mention_author=False) return # Check if role is assignable by the bot. if message.guild.me.top_role.position < notifyrole.position: await message.reply("Notify role position is higher than the bots highest role. Please move the " - "notify role below the " + message.guild.me.top_role.name + " role.") + "notify role below the " + message.guild.me.top_role.name + " role.", + mention_author=False) return # Step 2 - Check if we already are on if message.guild.id in mydata['notifyserver']: # Is notify on? @@ -835,7 +838,7 @@ async def managehandler(command, message): if notifyrole.id != mydata['notifymsg'][savedmsgid]: mydata['notifymsg'][savedmsgid] = notifyrole.id msg += " . The stored notify role ID did not match the found role. It has been reset." - await message.reply(msg) + await message.reply(msg, mention_author=False) if not foundmsg.pinned: # Try to pin the message if it isn't. try: await foundmsg.pin() @@ -854,7 +857,7 @@ async def managehandler(command, message): sentmsg = await message.reply( "Notifications are enabled for this server. To receive a notification when stream announcements are set, " "please react to this message with :sound:. To stop receiving notifications, unreact the :sound: " - "reaction.\nIt is HIGHLY recommended this message be left pinned for users to find!") + "reaction.\nIt is HIGHLY recommended this message be left pinned for users to find!", mention_author=False) # Step 4 - Add the server+msgid and msgid+roleid to the dicts. mydata['notifyserver'][message.guild.id] = sentmsg.id mydata['notifymsg'][sentmsg.id] = notifyrole.id @@ -870,14 +873,14 @@ async def managehandler(command, message): if not managerole: # Manage role doesn't exist, make it now as we'll need it managerole = await makeuserrole(message.guild) if not managerole: # This isn't due to permissions issues, as we check that above - await message.reply("Unable to obtain/create the necessary role for an unknown reason.") + await message.reply("Unable to obtain/create the necessary role for an unknown reason.", mention_author=False) return if managerole and (message.guild.me.top_role.position < managerole.position): msg = "Bot does not have permission to manage the " + managerole.name + " role due to the role's position." msg += "\nPlease ensure the " + managerole.name + " role is below the bots role." msg += "\n" + managerole.name + " position: " + str(managerole.position) + ". Bots highest position: " + str( message.guild.me.top_role.position) - await message.reply(msg) + await message.reply(msg, mention_author=False) return if command[0] == 'setupchan': if message.channel_mentions: # We can't do anything if they didn't include a channel @@ -886,7 +889,7 @@ async def managehandler(command, message): # Validate the mentions are in this guild. It SEEMS either Discord or discord.py doesn't include them # anyway, but just to be sure we're still gonna check it. if channel.guild != message.guild: - await message.reply("I could not find " + channel.name + " in this server.") + await message.reply("I could not find " + channel.name + " in this server.", mention_author=False) continue msg = channel.name + ": " # Set everyone role to be able to read but not send in the channel @@ -910,9 +913,9 @@ async def managehandler(command, message): msg += "\nRead+Send permissions given to role for channel " + channel.name except discord.Forbidden: msg += "\nFailed to give read+write permissions to management role for channel." - await message.reply(msg) + await message.reply(msg, mention_author=False) return - await message.reply("You must mention one or more channels to be setup.") + await message.reply("You must mention one or more channels to be setup.", mention_author=False) return if command[0] == 'add': added = set() @@ -931,7 +934,7 @@ async def managehandler(command, message): msg += "\nThe following users were not found and could not be added: " + ", ".join(notfound) if not msg: msg += "Unable to add any users due to unknown error." - await message.reply(msg) + await message.reply(msg, mention_author=False) if command[0] == 'remove': removed = set() msg = "" @@ -949,7 +952,7 @@ async def managehandler(command, message): msg += "\nThe following users were not found: " + ", ".join(notfound) if not msg: msg += "Unable to remove roles from any users due to unknown error." - await message.reply(msg) + await message.reply(msg, mention_author=False) # Add our context, default data is to have two empty dicts: notifyserver and notifymsg @@ -1299,7 +1302,7 @@ async def on_message(message): msg = client.user.name + " bot version " + str(version) msg += "\nPlease use '@" + client.user.name + " help' for help on using the bot." msg += "\nOnline help is available at <" + helpurl + ">." - await message.reply(msg) + await message.reply(msg, mention_author=False) elif command[1] in contexts: # print("calling module",command[1], command[2:]) # If we don't have permission to send messages in the channel, don't use @@ -1326,7 +1329,7 @@ async def on_message(message): msg = "Unknown module '" + command[ 1] + "'. Remember, you must specify the module name before the command - e.g. 'picarto " + " ".join( command[1:]) + "'" - await message.reply(msg) + await message.reply(msg, mention_author=False) # Used when joining a server. Might want something for this. Possibly a good time to setup mydata for contexts