15
15
#
16
16
#####################################
17
17
18
- #########################################
19
- #
20
- bot = commands . Bot ( command_prefix = '!' ) #
21
- VERSION = "v0.1-alpha" #
22
- ACTIVITY = discord .Game ("!help" ) #
23
- #
24
- #########################################
18
+ #####################################
19
+ #
20
+ COMMAND_PREFIX = '!' #
21
+ VERSION = "v0.1-alpha" #
22
+ ACTIVITY = discord .Game ("!help" ) #
23
+ #
24
+ #####################################
25
25
26
26
load_dotenv ()
27
- TOKEN = os .getenv ('DISCORD_TOKEN' )
27
+ TOKEN = os .getenv ('DISCORD_TOKEN' )
28
28
29
+ bot = commands .Bot (command_prefix = COMMAND_PREFIX )
29
30
30
- @bot .event
31
- async def on_ready ():
31
+
32
+ @bot .event
33
+ async def on_connect ():
32
34
"""
33
- Logs a message with bot name and version when the bot starts. Sets the
34
- bot activity to ACTIVITY.
35
+ Prints a message with bot name and version when bot connects to Discord servers.
36
+ Sets the bot activity to ACTIVITY.
35
37
"""
36
38
37
39
print (f'{ bot .user .name } { VERSION } has sucessfully connected to Discord.' )
38
40
await bot .change_presence (activity = ACTIVITY )
41
+
42
+
43
+ @bot .event
44
+ async def on_ready ():
45
+ """
46
+ Prints a list of guilds the bot is connected to when the bot is finished processing
47
+ date from Discord servers.
48
+ """
49
+
50
+ print ('Bot loading complete. Current guilds: ' , end = '' )
39
51
52
+ guilds = []
53
+ for guild in bot .guilds :
54
+ label = guild .name + " (" + str (guild .id ) + ")"
55
+ guilds .append (label )
56
+
57
+ print (* guilds , sep = ', ' )
58
+
59
+
60
+ @bot .event
61
+ async def on_disconnect ():
62
+ """
63
+ Prints a message when bot disconnects from Discord. Usually this is temporary.
64
+ """
65
+
66
+ print ('Lost connection to Discord.' )
67
+
40
68
41
69
42
70
@bot .event
@@ -116,54 +144,5 @@ async def on_message(message):
116
144
await message .channel .send (response )
117
145
break
118
146
119
- if 'hard' in message .content .lower () or 'long' in message .content .lower () or 'wet' in message .content .lower () or 'suck' in message .content .lower ():
120
- """
121
- Lets the bot tell the famous "That's what she said" joke
122
- """
123
-
124
- user_message = message .content .split ()
125
-
126
- dirty_words = [' hard' , ' long' , ' wet' , ' suck' ]
127
-
128
- for i in range (len (user_message )):
129
- word = user_message [i ].lower ().strip ("?" ).strip ('"' ).strip ("'" )
130
-
131
- if (' ' + word in dirty_words ):
132
-
133
- print ("That's what she said incoming!" )
134
-
135
- response = "That's what she said!"
136
- print (response )
137
- await message .channel .send (response )
138
- break
139
-
140
-
141
- @bot .command (name = '99' , help = 'Responds with a random Brooklyn 99 quote.' )
142
- async def nine_nine (ctx ):
143
- b99_quotes = [
144
- "I'm the human form of the 💯 emoji." ,
145
- "Bingpot!" ,
146
- "Nine-nine!" ,
147
- (
148
- "Cool. Cool cool cool cool cool cool cool, "
149
- "no doubt no doubt no doubt no doubt."
150
- ),
151
- "With all due respect, I am gonna completely ignore everything you just said." ,
152
- (
153
- "The English language can not fully capture the depth and complexity of my "
154
- "thoughts, so I’m incorporating emojis into my speech to better express myself. 😉."
155
- ),
156
- "I’d like your $8-est bottle of wine, please." ,
157
- "But if you’re here, who’s guarding Hades?"
158
- ]
159
-
160
- response = random .choice (b99_quotes )
161
- await ctx .send (response )
162
-
163
-
164
- @bot .command (name = 'raise-exception' , help = 'Logs an exception with message data. Developer use.' )
165
- async def raise_exception (ctx ):
166
- await ctx .send ('Raising an exception to my console...' )
167
- raise discord .DiscordException
168
147
169
148
bot .run (TOKEN )
0 commit comments