Skip to content

Commit c63ed9d

Browse files
committed
Merge from master, make presence intent default off
2 parents 766bbbb + b84b26f commit c63ed9d

File tree

6 files changed

+122
-28
lines changed

6 files changed

+122
-28
lines changed

CHANGELOG.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ however, insignificant breaking changes do not guarantee a major version bump, s
99

1010
# [Unreleased]
1111

12-
### Fixed
12+
### Breaking
1313

14-
- Bots without presence intent encountering RuntimeError on start.
14+
- Presence intent is now by-default OFF. You can turn it on by setting `ENABLE_PRESENCE_INTENT=true` in the environment variables.
1515

16+
### Fixed
17+
18+
- Resolved an issue where `?logs` doesn't work when the thread has no title. ([PR #3201](https://github.com/kyb3r/modmail/pull/3201))
1619

1720
# v4.0.1
1821

@@ -26,7 +29,6 @@ This is a hotfix release.
2629

2730
- Thread cooldown
2831

29-
3032
# v4.0.0
3133

3234
### Breaking

bot.py

+13-22
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@
6666

6767
class ModmailBot(commands.Bot):
6868
def __init__(self):
69+
self.config = ConfigManager(self)
70+
self.config.populate_cache()
71+
6972
intents = discord.Intents.all()
73+
if not self.config['enable_presence_intent']:
74+
intents.presences = False
75+
7076
super().__init__(command_prefix=None, intents=intents) # implemented in `get_prefix`
7177
self.session = None
7278
self._api = None
@@ -76,9 +82,6 @@ def __init__(self):
7682
self.start_time = discord.utils.utcnow()
7783
self._started = False
7884

79-
self.config = ConfigManager(self)
80-
self.config.populate_cache()
81-
8285
self.threads = ThreadManager(self)
8386

8487
self.log_file_name = os.path.join(temp_dir, f"{self.token.split('.')[0]}.log")
@@ -218,26 +221,14 @@ async def runner():
218221
async with self:
219222
self._connected = asyncio.Event()
220223
self.session = ClientSession(loop=self.loop)
224+
225+
if self.config['enable_presence_intent']:
226+
logger.info("Starting bot with presence intent.")
227+
else:
228+
logger.info("Starting bot without presence intent.")
229+
221230
try:
222-
retry_intents = False
223-
try:
224-
await self.start(self.token)
225-
except discord.PrivilegedIntentsRequired:
226-
retry_intents = True
227-
if retry_intents:
228-
if self.ws is not None and self.ws.open:
229-
await self.ws.close(code=1000)
230-
self._ready.clear()
231-
232-
intents = discord.Intents.default()
233-
intents.members = True
234-
intents.message_content = True
235-
# Try again with members intent
236-
self._connection._intents = intents
237-
logger.warning(
238-
"Attempting to reconnect with only the server members and message content privileged intent. Some plugins might not work correctly."
239-
)
240-
await self.connect(reconnect=True)
231+
await self.start(self.token)
241232
except discord.PrivilegedIntentsRequired:
242233
logger.critical(
243234
"Privileged intents are not explicitly granted in the discord developers dashboard."

cogs/modmail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def format_log_embeds(self, logs, avatar_url):
749749
if entry["recipient"]["id"] != entry["creator"]["id"]:
750750
embed.add_field(name="Created by", value=f"<@{entry['creator']['id']}>")
751751

752-
if entry["title"]:
752+
if entry.get("title"):
753753
embed.add_field(name="Title", value=entry["title"], inline=False)
754754

755755
embed.add_field(name="Preview", value=format_preview(entry["messages"]), inline=False)

core/config.py

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class ConfigManager:
166166
"database_type": "mongodb",
167167
"connection_uri": None, # replace mongo uri in the future
168168
"owners": None,
169+
"enable_presence_intent": False,
169170
# bot
170171
"token": None,
171172
"enable_plugins": True,
@@ -221,6 +222,7 @@ class ConfigManager:
221222
"thread_show_account_age",
222223
"thread_show_join_age",
223224
"use_hoisted_top_role",
225+
"enable_presence_intent",
224226
}
225227

226228
enums = {

plugins/registry.json

+100-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
{
2+
"advanced-menu": {
3+
"repository": "sebkuip/mm-plugins",
4+
"branch": "master",
5+
"description": "Advanced menu plugin using dropdown selectors. Supports submenus (and sub-submenus infinitely).",
6+
"bot_version": "v4.0.0",
7+
"title": "Advanced menu",
8+
"icon_url": "https://raw.githubusercontent.com/sebkuip/mm-plugins/master/advanced-menu/logo.png",
9+
"thumbnail_url": "https://raw.githubusercontent.com/sebkuip/mm-plugins/master/advanced-menu/logo.png"
10+
},
11+
"announcement": {
12+
"repository": "Jerrie-Aries/modmail-plugins",
13+
"branch": "master",
14+
"description": "Create and post announcements. Supports both plain and embed. Also customisable using buttons and dropdown menus.",
15+
"bot_version": "4.0.0",
16+
"title": "Announcement",
17+
"icon_url": "https://github.com/Jerrie-Aries.png",
18+
"thumbnail_url": "https://raw.githubusercontent.com/Jerrie-Aries/modmail-plugins/master/.static/announcement.jpg"
19+
},
20+
"giveaway": {
21+
"repository": "Jerrie-Aries/modmail-plugins",
22+
"branch": "master",
23+
"description": "Host giveaways on your server with this plugin.",
24+
"bot_version": "4.0.0",
25+
"title": "Giveaway",
26+
"icon_url": "https://github.com/Jerrie-Aries.png",
27+
"thumbnail_url": "https://raw.githubusercontent.com/Jerrie-Aries/modmail-plugins/master/.static/giveaway.jpg"
28+
},
229
"suggest": {
330
"repository": "realcyguy/modmail-plugins",
431
"branch": "v4",
@@ -7,5 +34,77 @@
734
"title": "Suggest stuff.",
835
"icon_url": "https://i.imgur.com/qtE7AH8.png",
936
"thumbnail_url": "https://i.imgur.com/qtE7AH8.png"
37+
},
38+
"welcomer": {
39+
"repository": "fourjr/modmail-plugins",
40+
"branch": "v4",
41+
"description": "Add messages to welcome new members! Allows for embedded messages as well. [Read more](https://github.com/fourjr/modmail-plugins/blob/master/welcomer/README.md)",
42+
"bot_version": "4.0.0",
43+
"title": "New member messages plugin",
44+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
45+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
46+
},
47+
"countdowns": {
48+
"repository": "fourjr/modmail-plugins",
49+
"branch": "v4",
50+
"description": "Setup a countdown voice channel in your server!",
51+
"bot_version": "4.0.0",
52+
"title": "Countdowns",
53+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
54+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
55+
},
56+
"claim": {
57+
"repository": "fourjr/modmail-plugins",
58+
"branch": "v4",
59+
"description": "Allows supporters to claim thread by sending ?claim in the thread channel",
60+
"bot_version": "4.0.0",
61+
"title": "Claim Thread",
62+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
63+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
64+
},
65+
"emote-manager": {
66+
"repository": "fourjr/modmail-plugins",
67+
"branch": "v4",
68+
"description": "Allows managing server emotes via ?emoji",
69+
"bot_version": "4.0.0",
70+
"title": "Emote Manager",
71+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
72+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
73+
},
74+
"gen-log": {
75+
"repository": "fourjr/modmail-plugins",
76+
"branch": "v4",
77+
"description": "Outputs a text log of a thread in a specified channel",
78+
"bot_version": "4.0.0",
79+
"title": "Log Generator",
80+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
81+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
82+
},
83+
"media-logger": {
84+
"repository": "fourjr/modmail-plugins",
85+
"branch": "v4",
86+
"description": "Re-posts detected media from all visible channels into a specified logging channel",
87+
"bot_version": "4.0.0",
88+
"title": "Media Logger",
89+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
90+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
91+
},
92+
"report": {
93+
"repository": "fourjr/modmail-plugins",
94+
"branch": "v4",
95+
"description": "Specify an emoji to react with on messages. Generates a 'report' in specified logging channel upon react.",
96+
"bot_version": "4.0.0",
97+
"title": "Report",
98+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
99+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
100+
},
101+
"top-supporters": {
102+
"repository": "fourjr/modmail-plugins",
103+
"branch": "v4",
104+
"description": "Gathers and prints the top supporters of handling threads.",
105+
"bot_version": "4.0.0",
106+
"title": "Top Supporters",
107+
"icon_url": "https://i.imgur.com/Mo60CdK.png",
108+
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
10109
}
11-
}
110+
}

runtime.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.10.3
1+
python-3.10.7

0 commit comments

Comments
 (0)