Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
chatbot/main.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 lines (36 sloc)
1.36 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import discord | |
from discord.ext import commands | |
import sys, traceback | |
from botClient import client | |
from botClient import botToken | |
import guessFile | |
extensions = ['test', 'basicFunctionsFile', 'helpFile', 'guessFile'] #Extensions list | |
@client.event | |
async def on_ready(): | |
print('Logged in as') | |
print(client.user.name) | |
print('CID: ' + str(client.user.id)) | |
print('-----------------------') | |
if __name__ == '__main__': #Load extensions from other modules | |
for extension in extensions: | |
try: | |
client.load_extension(extension) | |
except Exception as error: | |
print(f'{extension} cannot be loaded [{error}]') | |
@client.event | |
async def on_message(message): | |
if message.author == client.user: | |
return | |
if message.content == 'hai': | |
await message.channel.send('YES') | |
await client.process_commands(message) #So that events don't disable commands | |
@client.event | |
async def on_member_join(member): | |
# print(ctx.author.guild.name) testing | |
await message.channel.send(f'Welcome {member.mention} to {member.guild.name}!') | |
await client.process_commands(message) #So that events don't disable commands | |
@client.command() | |
async def ctest(ctx): | |
await ctx.send('I heard you! {}'.format(ctx.author.mention)) | |
client.run(botToken) |