# Imports
import discord
import random
import os
from discord.ext import commands
from keep_alive import keep_alive
# Credentials
TOKEN = os.environ['Token']
# Create bot
client = commands.Bot(command_prefix='Aimby')
badword = ["word1","word2","word3"]
censorprotocol = False
# Startup Information
@client.event
async def on_ready():
print('Starting bot: {}'.format(client.user.name))
print('Status: Online')
@client.event
async def on_message(message):
#Aimby censoring
censorprotocol = False
if message.content.startswith('Aimby initiate censor protocol'):
if censorprotocol == False:
await message.channel.send("Censoring bad words.")
censorprotocol = True
else:
await message.channel.send("Already censoring bad words.")
if message.content.startswith('Aimby complete censor protocol'):
if censorprotocol == True:
await message.channel.send("Stopped censoring bad words.")
censorprotocol = False
else:
await message.channel.send("Currently not censoring bad words.")
while censorprotocol == True:
if censorprotocol == True and any(word in message.content.lower() for word in badword):
await message.delete()
await message.channel.send("Language!")
else:
return
keep_alive()
client.run(TOKEN)
So I want to create a boolean variable that would normally be false. When I say "Aimby initiate censor protocol" it should make the variable true, thus also triggering the while loop. But for some reason, the "censorprotocol" variable does not change states (true or false) and the bot doesn't read the text in the while loop (plus I don't think it works).