Creating a mod bot for Discord

Hello. I used the video for “Code a Discord Bot with Python - Host for Free in the Cloud”. The only item I didn’t use is the inspire stuff. I want a basic bot for moderating a Discord server. I can’t seem to get things to work for the Keep Alive set up & UpTime set up. I typed in everything as it was shown on the video but get nothing. I have a good sized list of banned words that I would like to be used for moderation but don’t know how to set up the coding for it. The owner of the server & I want to keep it as family friendly as possible. Also, We want it to search the worded status for any of the banned words in the list, like what is in the pic.
Screenshot_4
Can someone please help me with this. I would like to get the bot up and running as soon as possible. Thanks

1 Like

Hi @ruffone89048. I would request you to share some of your code in order to figure out the problem. I would love to help you in this topic.

Thank you for the reply. Here is the coding that I have for each of the files I created according to the video.

This is the coding for the main.py file:
import discord
import os
from keep_alive import keep_alive
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):
if message.author == client.user:return

if message.content. startswith(’$hello’):
await message.channel.send(‘Hello!’)keep
keep_alive()
client.run(os.getenv(‘TOKEN’))

This is the coding for the Keep Alive file:

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()

When entered as shown on the video and above, I do not get the “Hello. I am alive! web thing on the side of the screen to put into the UpTime Robot” site.

I am currently having someone trying to work on a bot for the server but they are having a lot of bug issues and I am getting tired of waiting for them to get it done. They are in school but it seems like they are not having much time to work on the bug issue. I do have a copy of the files for that if needed. If so, please let me know. I hope this is of some help. Thanks.

Okay, let’s start Debugging your problem.

Problem Identification

This is what I undestood the problem is:

  • Unable to see 'Hello. I am alive!', just like the tutorial.
  • Unable to create programming logic for discord moderation bot, as per the main question is concerned.
Answers
  1. I would reckon you to again view the tutorial and watch out for small details, said by @beaucarnes. Even if you still confused, it’s all about

Replit .Replit is an online interpreter when you can write and store your files in your account. Replit also has a feature to run the programs background using the web server. When you apply the code for Keep_Alive.py, Replit will automatically create a web url for the concerned program and then you can monitor it using Uptime Robot. I hope this satisfies with your first part of the question.

  1. Algorithmic Problem.
    Honestly speaking, in Freecodecamp I am not supposed to spoon-feed you with the solutions. We can only help you with the logics and some errors which can be rectified. Rest is all in your hands. In case you want any help, you can add me in your Discord group as a BOT Developer.

I hope I have answered all your queries and I would love to hear your progress.
Happy Coding!

@mondalraif450

Thank you for your help. I have reviewed the video many times and still not getting anywhere. Besides sending you an invite on here to my test server that I set up to do the testing with, How would I get an invite to you. I have set up a role just for Bot developer. I also am not allowing many people onto the server because eventually once the new bot is up and going, it will go to a different server. Please let me know. Thanks.

Give an invite on Adorable Trooper #3828