A
A
assbeater4202021-01-25 21:19:35
Python
assbeater420, 2021-01-25 21:19:35

How to make a "variable" whose value will be the command argument?

I am writing a bot on Pydroid.

The code:

import discord
from discord.ext import commands
import asyncio


Bot = commands.Bot(command_prefix='!') #префикс
token = '?'# токен

@Bot.command()
async def test(ctx):
    argument = ??? #аргумент_команды


How to make if the user writes !test 1 , then the value of "variable" or whatever it is, will be equal to 1?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WolfInChains, 2021-01-25
@assbeater420

You can split the string through split and assign it through the index

text = "Один два три четыре"
result = text.split(" ")
print(result[1])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question