Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python Server for Discord Bot
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Hello. I am alive!"
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = Thread(target=run)
t.start()
@humaniterrorist
Copy link

humaniterrorist commented Feb 4, 2021

who is BEau

Top left of this page shows you who created it.

@AlongDeveloper
Copy link

AlongDeveloper commented Feb 17, 2021

hey boys

@alconYT
Copy link

alconYT commented Feb 24, 2021

hello

@fishmasterswimmer
Copy link

fishmasterswimmer commented Feb 27, 2021

thank you

@Cyber71Gaming
Copy link

Cyber71Gaming commented Mar 8, 2021

tnx

@ksonawat007
Copy link

ksonawat007 commented Mar 28, 2021

I tried this tutorial and had the question if the repl.it database could be used on our local machines as well.
And help is appreciated!

@CrypticMDev
Copy link

CrypticMDev commented Mar 31, 2021

This is amazing thank you Beau

@Chhunneng
Copy link

Chhunneng commented Apr 12, 2021

Good Idea

Copy link

ghost commented May 14, 2021

Hey I really appreciate the tutorial. I was wondering if anyone else was experiencing an issue with versions of replit and flask.

[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1

This error only came up after I added the database code. I would be grateful for any help.

@SamuraiZen28
Copy link

SamuraiZen28 commented May 16, 2021

Hey I really appreciate the tutorial. I was wondering if anyone else was experiencing an issue with versions of replit and flask.

[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1

This error only came up after I added the database code. I would be grateful for any help.

Yes I don't think this works anymore... I had the same thing happen

@prashant2-4-4
Copy link

prashant2-4-4 commented May 17, 2021

[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1

same problem plz help

@manasa-sm
Copy link

manasa-sm commented May 17, 2021

Hey I really appreciate the tutorial. I was wondering if anyone else was experiencing an issue with versions of replit and flask.

[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1

This error only came up after I added the database code. I would be grateful for any help.

facing with the same issue

@phanhoang1366
Copy link

phanhoang1366 commented May 22, 2021

Hey I really appreciate the tutorial. I was wondering if anyone else was experiencing an issue with versions of replit and flask.
[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1
This error only came up after I added the database code. I would be grateful for any help.

facing with the same issue

found the solution! you need to add flask = "1.1.4" line to pyproject.toml before the [tool.poetry.dev-dependencies] line

@Oeshik
Copy link

Oeshik commented May 22, 2021

Hey I really appreciate the tutorial. I was wondering if anyone else was experiencing an issue with versions of replit and flask.
[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1
This error only came up after I added the database code. I would be grateful for any help.

facing with the same issue

found the solution! you need to add flask = "1.1.4" line to pyproject.toml before the [tool.poetry.dev-dependencies] line

thank you so much you beautiful human being

@Chelsi-create
Copy link

Chelsi-create commented May 23, 2021

Hey I really appreciate the tutorial. I was wondering if anyone else was experiencing an issue with versions of replit and flask.
[SolverProblemError] Because no versions of replit match >3.0.0,<4.0.0 and replit (3.0.0) depends on flask (>=1.1.2,<2.0.0), replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0). So, because repl-python3-practicebot depends on both flask (^2.0.0) and replit (^3.0.0), version solving failed. exit status 1
This error only came up after I added the database code. I would be grateful for any help.

facing with the same issue

found the solution! you need to add flask = "1.1.4" line to pyproject.toml before the [tool.poetry.dev-dependencies] line

thank you so much for this solution, this is working!

@Indianjuf
Copy link

Indianjuf commented Aug 13, 2021

Nice

@zenix912
Copy link

zenix912 commented Aug 14, 2021

bro im a 12 year old trying to make a bot for my fortnite clan can some one tell me what this is?

@Chhunneng
Copy link

Chhunneng commented Aug 14, 2021

bro im a 12 year old trying to make a bot for my fortnite clan can some one tell me what this is?

This one we use to keep bot still work after you left the server.

@zenix912
Copy link

zenix912 commented Aug 14, 2021

bro i still dont understand how this thing works bro

@zenix912
Copy link

zenix912 commented Aug 14, 2021

i,ve been coding for 2 hours yet i still dont get it bro

@zenix912
Copy link

zenix912 commented Aug 14, 2021

just for my clan

@Chhunneng
Copy link

Chhunneng commented Aug 14, 2021

bro i still dont understand how this thing works bro

Here you can check the video about it. He will explain how it works.

@Onija-Dissanayake
Copy link

Onija-Dissanayake commented Aug 21, 2021

Tysm

@Onija-Dissanayake
Copy link

Onija-Dissanayake commented Aug 21, 2021

Tysm

@xtho25
Copy link

xtho25 commented Dec 14, 2021

I am not getting the link for a reason. Please help

@AhmeddTerminator
Copy link

AhmeddTerminator commented Dec 16, 2021

the correct code is :

@AhmeddTerminator
Copy link

AhmeddTerminator commented Dec 16, 2021

import discord
import random

TOKEN = 'OTIwOTUzNTk3ODQyMzIxNDA4.Ybr24A.V5i-XSMPCDP8FrLWbLjseIE5MZY'

client = discord.Client()

@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f'{username}: {user_message} ({channel})')

if message.author == client.user:
    return

if message.channel.name == 'general':
    if user_message.lower() == 'hello':
        await message.channel.send(f'Hello {username}')
        return
    elif user_message.lower() == "bye":
        await message.channel.send(f'see you later{username}')
        return
    elif user_message.lower() == "!random":
        response = f'This is your random number: {random.randrange(1000000)}'
        await message.channel.send(response)
        return

client.run(TOKEN)

@TecFuture
Copy link

TecFuture commented Jan 22, 2022

I did everything here but I get the error:
Traceback (most recent call last):
File "main.py", line 4, in
import keep_alive
ModuleNotFoundError: No module named 'keep_alive'

@dechire20
Copy link

dechire20 commented Feb 18, 2022

I ran to an error I don't know how to solve it .
I have used this for the last 5 months and didn't run into any error after looking into my replit I saw this and my bot doesn't run anymore.

  • Serving Flask app '' (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on all addresses.
    WARNING: This is a development server. Do not use it in a production deployment.
  • Running on http://172.18.0.177:8080/ (Press CTRL+C to quit)
    Traceback (most recent call last):
    File "main.py", line 46, in
    client.run(my_secret)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run
    return future.result()
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 216, in request
    raise HTTPException(r, data)
    discord.errors.HTTPException: 429 Too Many Requests (error code: 0):
<title>Access denied | discord.com used Cloudflare to restrict access</title> <script type="text/javascript"> (function(){if(document.addEventListener&&window.XMLHttpRequest&&JSON&&JSON.stringify){var e=function(a){var c=document.getElementById("error-feedback-survey"),d=document.getElementById("error-feedback-success"),b=new XMLHttpRequest;a={event:"feedback clicked",properties:{errorCode:1015,helpful:a,version:1}};b.open("POST","https://sparrow.cloudflare.com/api/v1/event");b.setRequestHeader("Content-Type","application/json");b.setRequestHeader("Sparrow-Source-Key","c771f0e4b54944bebf4261d44bd79a1e"); b.send(JSON.stringify(a));c.classList.add("feedback-hidden");d.classList.remove("feedback-hidden")};document.addEventListener("DOMContentLoaded",function(){var a=document.getElementById("error-feedback"),c=document.getElementById("feedback-button-yes"),d=document.getElementById("feedback-button-no");"classList"in a&&(a.classList.remove("feedback-hidden"),c.addEventListener("click",function(){e(!0)}),d.addEventListener("click",function(){e(!1)}))})}})(); </script> <script defer src="https://api.radar.cloudflare.com/beacon.js"></script> <script async src='/cdn-cgi/bm/cv/669835187/api.js'></script>

Error 1015

Ray ID: 6df521272f635fc8 • 2022-02-18 06:16:56 UTC

You are being rate limited

  <section class="w-240 lg:w-full mx-auto mb-8 lg:px-8">
      <div id="what-happened-section" class="w-1/2 md:w-full">
        <h2 class="text-3xl leading-tight font-normal mb-4 text-black-dark antialiased" data-translate="what_happened">What happened?</h2>
        <p>The owner of this website (discord.com) has banned you temporarily from accessing this website.</p>
        
      </div>

      
  </section>

  
  <div class="feedback-hidden py-8 text-center" id="error-feedback">
     <div id="error-feedback-survey">
        Was this page helpful?
        <button class="border border-solid bg-white cf-button cursor-pointer ml-4 px-4 py-2 rounded" id="feedback-button-yes" type="button">Yes</button>
        <button class="border border-solid bg-white cf-button cursor-pointer ml-4 px-4 py-2 rounded" id="feedback-button-no" type="button">No</button>
     </div>
     <div class="feedback-success feedback-hidden" id="error-feedback-success">
        Thank you for your feedback!
     </div>
  </div>
  

  <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">

Cloudflare Ray ID: 6df521272f635fc8 Your IP: 34.82.20.192 Performance & security by Cloudflare

</div><!-- /#cf-error-details -->
<script type="text/javascript"> window._cf_translation = {}; </script> <script type="text/javascript">(function(){window['__CF$cv$params']={r:'6df521272f635fc8',m:'fPqPP3uW0OfhczLfXbedaKsQs0mU.zfzvW3J2hfWEp4-1645165016-0-AQOfaTB6OLjNlnNDPVGkIBNeBEJV/qiMqlQvp/qOM5+VpzBQrPVqqUUndAkLhBo/1ZtAvRVf4TWIXB+9KuArRMMQNClyGw88ZGf2Nm/H+MDnlb+pqXI5kTyZSFg+dsL9jb9ztbF+ghyfhOD8cbHUz50=',s:[0xff0c6a9012,0x84f9054991],}})();</script>

@developer101234
Copy link

developer101234 commented Jun 20, 2022

help
Traceback (most recent call last):
File "site.py", line 1, in
from flask import Flask
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/init.py", line 14, in
from jinja2 import escape
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jinja2/init.py", line 12, in
from .environment import Environment
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jinja2/environment.py", line 25, in
from .defaults import BLOCK_END_STRING
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jinja2/defaults.py", line 3, in
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jinja2/filters.py", line 13, in
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/opt/virtualenvs/python3/lib/python3.8/site-packages/markupsafe/init.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment