Skip to content

Commit

Permalink
check dpy v, mention_chnanel_id, resolves #2880
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Nov 13, 2020
1 parent c5db7b9 commit dd9e25e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.

# 3.7.2

### Added
- Added `mention_channel_id` to specify which channel `alert_on_mention` was being sent to ([GH #2880](https://github.com/kyb3r/modmail/issues/2880))

# v3.7.1

### Fixed
Expand Down
27 changes: 25 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.7.1"
__version__ = "3.7.2"


import asyncio
Expand Down Expand Up @@ -252,6 +252,21 @@ def log_channel(self) -> typing.Optional[discord.TextChannel]:
)
return None

@property
def mention_channel(self):
channel_id = self.config["mention_channel_id"]
if channel_id is not None:
try:
channel = self.get_channel(int(channel_id))
if channel is not None:
return channel
except ValueError:
pass
logger.debug("MENTION_CHANNEL_ID was invalid, removed.")
self.config.remove("mention_channel_id")

return self.log_channel

async def wait_for_connected(self) -> None:
await self.wait_until_ready()
await self._connected.wait()
Expand Down Expand Up @@ -1002,7 +1017,7 @@ async def on_message(self, message):
color=self.main_color,
timestamp=datetime.utcnow(),
)
await self.log_channel.send(content=self.config["mention"], embed=em)
await self.mention_channel.send(content=self.config["mention"], embed=em)

await self.process_commands(message)

Expand Down Expand Up @@ -1504,6 +1519,14 @@ def main():
except ImportError:
pass

# check discord version
if discord.__version__ != "1.5.2":
logger.error(
"Dependencies are not updated, run pipenv install. discord.py version expected 1.5.2, recieved %s",
discord.__version__,
)
sys.exit(0)

bot = ModmailBot()
bot.run()

Expand Down
1 change: 1 addition & 0 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ async def about(self, ctx):
embed.add_field(name="Latency", value=f"{self.bot.latency * 1000:.2f} ms")
embed.add_field(name="Version", value=f"`{self.bot.version}`")
embed.add_field(name="Authors", value="`kyb3r`, `Taki`, `fourjr`")
embed.add_field(name="Hosting Method", value=self.bot.hosting_method.name)

changelog = await Changelog.from_url(self.bot)
latest = changelog.latest_version
Expand Down
1 change: 1 addition & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ConfigManager:
"plain_reply_without_command": False,
# logging
"log_channel_id": None,
"mention_channel_id": None,
# threads
"sent_emoji": "✅",
"blocked_emoji": "🚫",
Expand Down
11 changes: 11 additions & 0 deletions core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@
"If the Modmail logging channel ended up being non-existent/invalid, no logs will be sent."
]
},
"mention_channel_id": {
"default": "Log Channel (normally `#bot-logs`)",
"description": "This is the channel where bot mentions are sent to.",
"examples": [
"`{prefix}config set mention_channel_id 9234932582312` (9234932582312 is the channel ID)"
],
"notes": [
"This has no effect unless `alert_on_mention` is set to yes.",
"See also: `log_channel_id`"
]
},
"sent_emoji": {
"default": "",
"description": "This is the emoji added to the message when when a Modmail action is invoked successfully (ie. DM Modmail, edit message, etc.).",
Expand Down

0 comments on commit dd9e25e

Please sign in to comment.