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-ALL-Project/discord_server.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
39 lines (27 sloc)
1.27 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
# Lukas code starts here | |
import discord | |
"""Discord.py is a library used to communicate with discord and control your bot. | |
Source: https://github.com/Rapptz/discord.py""" | |
from discord.ext import commands | |
"""A part of the discord.py library that introduces bot (or user) commands you can use for easier control.""" | |
import logging | |
from main_function import Main_function | |
logging.basicConfig(level=logging.INFO) # Outputs basic log on the server side | |
TOKEN = "Mzc1MjU4NTE4NjYxNDk2ODMy.DPhj5A.wNcnniW9oibG4rcX6N7YNXJb6yM" # Unique to every bot, needed to authorise and run | |
CHANNEL = "375284753613455361" # Testing channel ID | |
description = '''A ChatBot made for ALL project''' | |
bot = commands.Bot(command_prefix='~', description=description) # Initializes bot object, specifies command prefix (~) and description | |
# This specific @bot.event (on_ready()) was taken from the basic_bot.py example in the discord.py repository. | |
@bot.event | |
async def on_ready(): | |
print('------\nLogged in as') | |
print(bot.user.name) | |
print(bot.user.id) | |
print('------') | |
@bot.event | |
async def on_message(message): | |
if message.author != bot.user: | |
msg = Main_function(message.content) | |
await bot.send_message(bot.get_channel(CHANNEL), msg) | |
bot.run(TOKEN) | |
# Lukas code ends here |