Ok, so in the following code it’s a very simple discord bot which is supposed to start a loop when someone’s message starts with “.loop”. However with the command being typed the loop or the process does not start. What is the reasoning for this?
import discord
import random
import time
import multiprocessing
def boop():
while True:
time.sleep(1)
print("I am looping.")
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(".loop"):
if __name__ == '__main__':
time.sleep(1)
p1 = multiprocessing.Process(target=boop)
p1.start()
client.run("yes")