Ask coding questions

← Back to all posts
Banlist
Coolboy62ksi (0)

Hay i wanted to find out if theres any code out there i can use to make abusive discord moderators so they cant use any of my bot commands so like a blacklist really but im calling it banlist if there is a response would be brilliant

Answered by VulcanWM (2770) [earned 5 cycles]
View Answer
Comments
hotnewtop
VulcanWM (2770)

do

#importing the replit module so you can access the replitdb where you save the people who have been banned
from replit import db
#adding someone to the banlist
def addbanlist(id):
  db[str(id)] = ['Banned']
#checking if a user is in the banlist, will return True if they are, will return False if they're not
def checkifbanned(id):
  if str(id) in db.keys():
    return True
  else: 
    return False
Coolboy62ksi (0)

@VulcanWM thank you for the code will this be able to go in my main.py or will it need a new file made for it

VulcanWM (2770)

np! mark the comment as the answer please @Coolboy62ksi

Coolboy62ksi (0)

@VulcanWM please answer my question first dose it go in my main.py or anther file?

Coolboy62ksi (0)

How do i even add people to the banlist @VulcanWM

VulcanWM (2770)

If u put it in functions.py you can do
from functions import *
then you can do the functions in main.py
if u write the functions in main.py then just do the functions @Coolboy62ksi

VulcanWM (2770)

using the function
addbanlist(discorduserid)
@Coolboy62ksi

Coolboy62ksi (0)

Im still a beginner i dont get what you mean @VulcanWM

Coolboy62ksi (0)

And i only have a main.py @VulcanWM

VulcanWM (2770)

Just whenever you want to add someone to the banlist, do the code below
db[‘discorduserid’] = ‘Banned’
insuring you have done from replit import db before @Coolboy62ksi

Coolboy62ksi (0)

I dont get what your saying i need help so i could invite you into my bot to do the code but it wont be the actual bot the code is in a test bot ready to be put into my [email protected]
https://replit.com/join/tawsmiks-coolboy62ksi

VulcanWM (2770)

I added one change to the code
Check it out @Coolboy62ksi

Coolboy62ksi (0)

Sorry to bother again but how do i get there [email protected]

Coolboy62ksi (0)

And dose it stop people from using the bots [email protected]

VulcanWM (2770)

ctx.author.id if ur using ctx in the discord function @Coolboy62ksi

Coolboy62ksi (0)

Im no coder for the banlist lol is there chance you can give the code the ability to stop people using the commands this is for abusing admins you see to stop them abusing @VulcanWM

Coolboy62ksi (0)

No and that’s because i have a help command that will list it and i want just me to have access to it @VulcanWM

Coolboy62ksi (0)

So when someone abused my bot i can ban them even if its adding someone inside my bots code and not using a command in discord if it stops them using the commands then that will be fine @VulcanWM

VulcanWM (2770)

Are u doing ur command like
@client.command()
async def command(ctx):
?

Coolboy62ksi (0)

No i dont want it to be a command as i said anyone will be able to use it i want to use the banlist from my bot code so no one can use it it is going to be used for people that abuse so i dont want anyone to use it just me as the owner @VulcanWM

VulcanWM (2770)

Yeah I know but do u use it in commands? @Coolboy62ksi

Coolboy62ksi (0)

No it has not get ctx on it
@VulcanWM

VulcanWM (2770)

then how does your commands look? @Coolboy62ksi

Coolboy62ksi (0)

All other commands like mod and other commands are ctx commands and embed commands the help command automatically adds the new commands thats why i want to this banlist to only allow me to use it to stop others using the bot commands this banlist i want to use it to stop abusers so inside the repl so i want to ban a user using my repl and not a command on discord if you need access to do the code to help my bot let me know @VulcanWM

VulcanWM (2770)

yeah if i could see the bot code that would be nice @Coolboy62ksi

VulcanWM (2770)

Yeah trust me I won’t do anything with the code except make the banlist @Coolboy62ksi

VulcanWM (2770)

Added it to most commands which needed it
btw there were so many errors in ur code
and make sure to hide the token and delete the invite link so nobody else can join @Coolboy62ksi

Coolboy62ksi (0)

Why is the addbanlist got a # at the start making it go blue @VulcanWM

VulcanWM (2770)

oh yeah i did that because if u run it many times it might show an error @Coolboy62ksi

Coolboy62ksi (0)

@VulcanWM to be honest i cant work out this problem but it gives line errors to lines that don’t exist yet

Coolboy62ksi (0)

Do you have discord by any chance as its easy because my emails are getting spammed @VulcanWM

VulcanWM (2770)

wdym can u screenshot the errors and send them here @Coolboy62ksi

VulcanWM (2770)

nah my account got disabled @Coolboy62ksi

Coolboy62ksi (0)

@VulcanWM was there a reason why if you dont mind me Asking

Coolboy62ksi (0)

@FishballNooodle i do not need this link thanks tho but its not got what im looking for