-Repl.it account
That's all you need.
Click "+ new repl".
Create a new repl.
Create "main.py".
#You need this at first.
import os
import keep_alive
# client.You need this before the run.
keep_alive.keep_alive()
#And client.run looks like this.
client.run(os.getenv('TOKEN'))
import discord
import os
import keep_alive
#Generate the objects needed for the connection
client = discord.Client()
#Processing that operates when receiving a message
@client.event
async def on_message(message):
if message.content == 'Secretary Jiàng':
await message.channel.send('Nyan')
await message.add_reaction('⭕')
#Launching a bot and connecting to a Discord server
keep_alive.keep_alive()
client.run(os.getenv('TOKEN'))
Create "help.txt".
discord.py
flask
Create "keep_alive.py".
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return 'Bot is aLive!'
def run():
app.run(host="0.0.0.0", port=8080)
def keep_alive():
server = Thread(target=run)
server.start()
Create ".env".
TOKEN = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Finally, click "run".
"poetry.lock" and "pyproject.toml" are automatically generated.
Recommended Posts