repl.it
@Lord_Poseidon/

TheMegaBot

Python

Discord bot for my classroom server

fork
loading
Files
  • main.py
  • keep_alive.py
  • Packager files
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import discord
import random
import googlesearch
import wikipedia
import keep_alive
keep_alive.keep_alive()

token=os.getenv('token')
client = discord.Client()

@client.event
async def on_message(message):
    hi=['hi','hlo','hey','sup','hello','hola','ciao','bonjour','hai','namste']
    if message.content.lower() in hi and not message.author == client.user:
        await message.channel.send(random.choice(hi))
    if message.content.startswith('google'):
        query=message.content.lower()[7:]
        a=googlesearch.search(query,stop=1)
        for i in a:
            await message.channel.send(i)
    if message.content.lower().startswith('wiki'):
        query=message.content.lower()[5:]
        try:
            await message.channel.send(wikipedia.summary(query))
        except discord.errors.HTTPException:
            for i in range(0,len(wikipedia.summary(query)),2000):
                await message.channel.send(wikipedia.summary(query)[i:i+2000])

client.run(token)
    
?