File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 15
15
"""
16
16
17
17
intents = discord .Intents .all ()
18
- bot = commands .Bot (command_prefix = PREFIX , intents = intents )
18
+
19
+
20
+ # inspired by https://github.com/Rapptz/RoboDanny
21
+ # This function will be evaluated for each message
22
+ # you can define specific behaviours for different messages or guilds, like custom prefixes for a guild etc...
23
+ def _prefix_callable (_bot : commands .Bot , msg : discord .Message ):
24
+
25
+ user_id = _bot .user .id
26
+ # way discord expresses mentions
27
+ # mobile and desktop have a different syntax how mentions are sent, so we handle both
28
+ prefixes = [f'<@!{ user_id } > ' , f'<@{ user_id } > ' ]
29
+ if msg .guild is None : # we're in DMs, using default prefix
30
+ prefixes .append (PREFIX )
31
+ return prefixes
32
+
33
+ # TODO: This would be the place to add guild specific custom prefixes
34
+ # you've got the current message hence the guild-id which is perfect to store and load prefixes for a guild
35
+ # just append them to base and only append the default prefix if there is no custom prefix for that guild
36
+
37
+ prefixes .append (PREFIX )
38
+ return prefixes
39
+
40
+
41
+ bot = commands .Bot (command_prefix = _prefix_callable , intents = intents )
19
42
20
43
21
44
# login message
You can’t perform that action at this time.
0 commit comments