fromdotenvimportdotenv_valuesfromclientimportClientfromdispatcherimportDispatcherfrommodules.utilsimportget_args# Creating a bot variable and put a bot token in itvalues=dotenv_values("../venv/.env")
token=values["TOKEN"]
bot=Client(token=token, log=False)
# Creating a command managerdp=Dispatcher(bot, command_prefix=[".", "bot."])
dp.enabled_help(enabled=False) # Disable help command, default enabled# Creates a prefix command that will repeat the text of the user@dp.add_command(name="echo")defecho(response):
# Initialize the variables that are important to us and that we will use furthermessage=response.parsed.auto()
args=get_args(response)
channel_id=message["channel_id"]
# If the argument is empty, we send an errorifnotargs:
returnbot.sendMessage(channel_id, "โ There is no text you would like to send, use like `{}echo`".format(
dp.command_prefix[0]
))
# Send a message to the channelbot.sendMessage(channel_id, args)
@bot.gateway.commanddefon_response(response):
ifresponse.event.ready_supplemental:
print("Bot is ready to use!")
ifresponse.event.message:
# We load all our commands in order to process themdp.process_commands(response)
# Let's launch our bot ๐bot.gateway.run(auto_reconnect=True)
A little bit about ../env/.env
TOKEN=bot_token
About
Command manager for the Discord S.C.U.M. (discum) library