Created
March 10, 2022 20:55
-
-
Save frostzzone/fd851c27822a7ac18e79f04b35e3b3a1 to your computer and use it in GitHub Desktop.
A simple python disocrd bot i made with a webserver for replit
This file contains hidden or 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
###commands### | |
## >pong - 'Ping!' | |
## /pling - 'Pong!' | |
## >test - 'Pong!' | |
## >ping - 'Pong! 100ms | |
import os | |
import disnake | |
from disnake.ext import commands | |
from flask import Flask | |
from threading import Thread | |
## True/False | |
replit = False | |
app = Flask('') | |
@app.route('/') | |
def main(): | |
return "This was made to keep your bot on 25/8" | |
def run(): | |
app.run(host="0.0.0.0", port=8080) | |
def keep_alive(): | |
server = Thread(target=run) | |
server.start() | |
bot = commands.Bot(command_prefix=">", test_guilds=[712405952745439302]) | |
#on ready | |
@bot.event | |
async def on_ready(): | |
print('logged in as {0.user}'.format(bot)) | |
@bot.event | |
async def on_message(message): | |
if message.author == bot.user: | |
return | |
if message.content.startswith('>pong'): | |
await message.channel.send('Ping!') | |
#slash | |
@bot.slash_command() | |
async def pling(inter): | |
await inter.response.send_message("Pong!") | |
#messages | |
@bot.command() | |
async def test(ctx): | |
await ctx.send('Pong!') | |
@bot.command() | |
async def ping(ctx): | |
await ctx.send(f'Pong! {round(bot.latency * 1000)} ms') | |
if replit == True: | |
keep_alive() | |
bot.run(os.environ['token']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment