I was making a discode dictionary bot. The function I want is for the user to enter a word and the meaning of the word through a command to the bot. So what's been conceived!It's input (word) (meaning), but the problem is that the bot separates words and their meanings by spaces, so if the meaning gets longer, only the sentence before the space is saved as meaning. For example, if you type !input anarchism is a~~, When you print it out, it only outputs up to anarchism. I think it's because there's a space between the word anarchism and is. Please look at my code and answer me how to fix it.
import discord
from discord.ext import commands
from discord.utils import get
bot = commands.Bot(command_prefix='!',intents=discord.Intents.all())
front_command = "!"
user_input = ""
user_output = ""
check_number = 0
@bot.event
async def on_ready():
print('Logging in..: ')
print(bot.user.name)
print('connection was succesful')
await bot.change_presence(status=discord.Status.online, activity=discord.Game("Testing"))
@bot.command()
async def input(ctx, arg1, arg2):
global check_number
temp_f = open("user.txt","r")
datafile = temp_f.readlines()
if len(datafile) == 0:
temp_f.close()
temp_f = open("user.txt","w")
temp_f.write(ctx.author.name + " " + str(arg1) + " " + str(arg2) +"\n")
await ctx.send("Registration completed!")
else:
for i in range(len(datafile)):
if arg1 in datafile[i]:
temp_f.close()
temp_f = open("user.txt","w")
datafile[i] = ctx.author.name + " " + str(arg1) + " " + str(arg2) +"\n"
temp_f.write('\n'.join(datafile))
await ctx.send("There is aleready "+str(arg1)+" related input, so it is changed to input now!")
check_number = 1
break
if check_number == 0:
temp_f = open("user.txt","w")
temp_f.write(ctx.author.name + " " + str(arg1) + " " + str(arg2) +"\n")
await ctx.send("Registration completed!")
check_number = 0
temp_f.close()
@bot.command()
async def output(ctx, arg1):
global check_number
temp_f = open("user.txt","r")
datafile = temp_f.readlines()
if len(datafile) == 0:
await ctx.channel.send("Nothing's registered yet! :)")
else:
for i in range(len(datafile)):
if arg1 in datafile[i]:
info = datafile[i].split()
msg = await ctx.send(str(info[2]))
await msg.reply(str(info[0]) + " " + "wrote this!")
check_number = 1
break
if check_number == 0:
await ctx.channel.send("Nothing's registered yet! :)")
check_number = 0
bot.run('Token')