Is it possible to create a 24/7 discord account with commands? (discord.py)

Viewed 986

I'm trying to create a discord account that are available 24/7, because I need to have a kind of "HelpDesk", so I need to have some pre-programmed commands to answer automatically when I'm not available.

import discord, os, keep_alive, asyncio, random
from discord.ext import commands

client = discord.Client()

@client.event
async def on_message(message):
  if message.author == client.user:
    return
  if message.content.find("<@&782663553492189204") != -1:
    await message.channel.send("Vamos te responder o mais rápido possível.")
  elif message.content.startswith("!TesteDM"):
    await message.author.send("Teste bem sucedido")

async def ch_pr():
  await client.wait_until_ready()

  nomes = ["help | @HelpDesk", "Faz-te sócio do NECC", "Máscara por 3€", "Visita o NECC", "Sala de Estudo", "bit.ly/calendárioLCC", "Convida Pessoal", "bit.ly/dropboxLCC", "bit.ly/pre-inscriçãoNECC"]

  while not client.is_closed():

    status = random.choice(nomes)

    await client.change_presence(activity=discord.Game(name=status))
    
    await asyncio.sleep(10)

client.loop.create_task(ch_pr())
keep_alive.keep_alive()
client.run(os.getenv("TOKEN"), bot = False)

The problem is when I try to implement some command like:

@client.command() 
async def kick(ctx, member : discord.member, * , reason=none): 
 await member.kick(reason=reason)

It doesn't work and I don't know why. I don't know if it only works with bot tokens or it could work with tokens of real accounts.

And where I have: client = discord.Client() I used to have:

client = commands.Bot(
  command_prefix='!',
  self_bot=True
) 
1 Answers

It's not working because discord.Client doesn't have the built-in command support, change this line client = discord.Client() to client = commands.Bot(command_prefix='some prefix') also you should enable some intents

Related