repl.it
Python

My discord bot

fork
loading
Files
  • main.py
  • keep_alive.py
  • mod.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import discord
import os
import asyncio
from discord.ext import commands
from discord.ext.commands import Bot
from keep_alive import keep_alive

bot_prefix = '!duck'
bot_description="DuckBot Beta"

bot = commands.Bot(command_prefix=bot_prefix, description=bot_description)

@bot.event
async def on_ready():
    print("I'm in")
    print(bot.user)

@bot.event
async def on_message(message):
    if message.content.startswith('!greet'):
        channel = message.channel
        await channel.send('Say hello!')

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if message.content == "Hello":
        await bot.send(message.channel, "World")

@bot.command()
async def load(extension_name : str):
    """Loads an extension."""
    try:
        bot.load_extension(extension_name)
    except (AttributeError, ImportError) as e:
        await bot.say("```py\n{}: {}\n```".format(type(e).__name__, str(e)))
        return
    await bot.say("{} loaded.".format(extension_name))
@bot.command()
async def unload(extension_name : str):
    """Unloads an extension."""
    bot.unload_extension(extension_name)
    await bot.say("{} unloaded.".format(extension_name))


token = os.environ.get("DISCORD_BOT_SECRET")
bot.run(token)
?