Skip to content

Commit ca265c8

Browse files
committed
Remove TWSS, B99, and raise-exception. Update event handlers (on_connect, on_ready, on_disconnect).
1 parent 733d272 commit ca265c8

File tree

1 file changed

+40
-61
lines changed

1 file changed

+40
-61
lines changed

protobot.py

Lines changed: 40 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,56 @@
1515
#
1616
#####################################
1717

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+
#####################################
2525

2626
load_dotenv()
27-
TOKEN = os.getenv('DISCORD_TOKEN')
27+
TOKEN = os.getenv('DISCORD_TOKEN')
2828

29+
bot = commands.Bot(command_prefix=COMMAND_PREFIX)
2930

30-
@bot.event
31-
async def on_ready():
31+
32+
@bot.event
33+
async def on_connect():
3234
"""
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.
3537
"""
3638

3739
print(f'{bot.user.name} {VERSION} has sucessfully connected to Discord.')
3840
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='')
3951

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+
4068

4169

4270
@bot.event
@@ -116,54 +144,5 @@ async def on_message(message):
116144
await message.channel.send(response)
117145
break
118146

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
168147

169148
bot.run(TOKEN)

0 commit comments

Comments
 (0)