elijabesu/SauriCogs

[Application] Error in apply and setapply questions

Closed this issue · 28 comments

After I set custom questions, an error happened for apply and setapply questions. I provided the traceback log below.

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 110, in apply
await ctx.author.send(question[0])
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/abc.py", line 935, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/http.py", line 247, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

Exception in command 'setapply questions'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 223, in setapply_questions
current_questions += "\n" + question[0]
TypeError: can only concatenate str (not "NoneType") to str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1340, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "NoneType") to str

I think you might have to reinstall the cog because the questions are saved in config. But I'll handle these exceptions so the commands would work later today.

I think you might have to reinstall the cog because the questions are saved in config. But I'll handle these exceptions so the commands would work later today.

so, i updated it after you released the new one. it still seems to error. I tried reinstalling it but still says the same thing.

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 111, in apply
await ctx.author.send(question[0])
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/abc.py", line 935, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/http.py", line 247, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message 

sighs, I'll try to figure something out... Sorry for the complications

I'm happy to help out with this. I'm not sure how this cog works yet, but from a quick look, question[0] does have a value, but its empty ''. I believe that will convert to NoneType, so we can just check if it exists in the function

I'm happy to help out with this. I'm not sure how this cog works yet, but from a quick look, question[0] does have a value, but its empty ''. I believe that will convert to NoneType, so we can just check if it exists in the function

The problem is that I rewrote the way the cog had the questions saved. Basically, I added questions parameter in self.config.register_guild which wasn't there before, so older versions of the cog don't have questions at all which is why it throws an error. And I need to figure out how to force the cog configuration to rewrite itself so it includes the questions parameter.

Theoretically, it could be resolved by changing the config identifier???? But I also don't wanna fuck it up even more lol.

Well iirc, if default config is updated, it should override the current settings of the cog they have installed. Changing the identifier would probably reset everything for all guilds/users when they update the cog, so kinda a tricky situation

Nvm, it seems that it is just having trouble getting the individual questions from the question list. This means [p]setapply questions is saving them incorrectly...

Yep, I was trying same_context check and didn't realize it worked differently than valid_int, so [p]setapply questions was saving None instead of the questions (credit to Jackenmen for figuring it out). Should be fixed and working now!

Awesome stuff, glad it's working for ya

it still seems to error. i tried reinstalling the cog as well.

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 110, in apply
await ctx.author.send(question[0])
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/abc.py", line 935, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/http.py", line 247, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

Exception in command 'setapply questions'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 224, in setapply_questions
current_questions += "\n" + question[0]
TypeError: can only concatenate str (not "NoneType") to str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1340, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "NoneType") to str

Oh yeah, that is because you did [p]setapply questions before I fixed it. I forgot that was still there, sorry. I'll push a quick fix to that asap.

Should be HOPEFULLY fixed now.

i think it's a different error now lol.

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 109, in apply
default_questions = _default_questions_list() # default list of lists just in case
NameError: name '_default_questions_list' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name '_default_questions_list' is not defined

Exception in command 'setapply questions'
Traceback (most recent call last):
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 232, in setapply_questions
current_questions += "\n" + question[0]
TypeError: can only concatenate str (not "NoneType") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 234, in setapply_questions
current_questions = "Uh oh, couldn't fetch your questions.\n" + _default_questions_string()
NameError: name '_default_questions_string' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1340, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name '_default_questions_string' is not defined

I've been working in Java for way too long, I forgot Python needs self hA, sorry.

I've been working in Java for way too long, I forgot Python needs self hA, sorry.

not a problem. coding is hard so it's totally understandable. the update seems to have a different error now.

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 109, in apply
default_questions = await self._default_questions_list() # default list of lists just in case
TypeError: _default_questions_list() takes 0 positional arguments but 1 was given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: _default_questions_list() takes 0 positional arguments but 1 was given 

How was 1 given when it's empty? aobgiojgiabvgiravrge >:(

When you fix it somewhere but forget to fix it somewhere else.

It should work now, hopefully...

When you fix it somewhere but forget to fix it somewhere else.

It should work now, hopefully...

umm.. i hate to be the bringer of bad news, but.. lol

Exception in command 'setapply questions'
Traceback (most recent call last):
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 232, in setapply_questions
current_questions += "\n" + question[0]
TypeError: can only concatenate str (not "NoneType") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 234, in setapply_questions
current_questions = "Uh oh, couldn't fetch your questions.\n" + await self._default_questions_string()
TypeError: can only concatenate str (not "NoneType") to str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1340, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "NoneType") to str 

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 112, in apply
await ctx.author.send(question[0])
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/abc.py", line 935, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/http.py", line 247, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message 

I am legit confused bc I've just tried it on my fresh bot (finally got one) and it works just fine for me??
image

I am legit confused bc I've just tried it on my fresh bot (finally got one) and it works just fine for me??
image

that's weird. i tried reinstalling already but still doesn't work though. is there a way to like clear everything for the cog? like a reset or something. maybe then it will work

You could unload the cog, delete the settings.json file, then load the cog, so a new settings.json would be created.

To do this: do [p]paths and copy the first Install Path but only before CogManager and then add Application to it (so for me, it's /home/elijabesu/.local/share/Red-DiscordBot/data/SauriBot/cogs/Application), then delete settings.json from the folder.

You could unload the cog, delete the settings.json file, then load the cog, so a new settings.json would be created.

To do this: do [p]paths and copy the first Install Path but only before CogManager and then add Application to it (so for me, it's /home/elijabesu/.local/share/Red-DiscordBot/data/SauriBot/cogs/Application), then delete settings.json from the folder.

neat instructions. i'll do that later cause i'm a bit sleepy. thanks for the huge effort in fixing the issue. really appreciated. i'll report back once i try it

so i tried deleting the settings.json but i'm still getting the error. it's weird how it works fine for you but not for me.

Exception in command 'apply'
Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 112, in apply
await ctx.author.send(question[0])
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/abc.py", line 935, in send
data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/http.py", line 247, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

Exception in command 'setapply questions'
Traceback (most recent call last):
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 232, in setapply_questions
current_questions += "\n" + question[0]
TypeError: can only concatenate str (not "NoneType") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/mkurisu069/.local/share/Red-DiscordBot/data/Redbot/cogs/CogManager/cogs/application/application.py", line 234, in setapply_questions
current_questions = "Uh oh, couldn't fetch your questions.\n" + await self._default_questions_string()
TypeError: can only concatenate str (not "NoneType") to str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/home/mkurisu069/redenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 832, in invoke
await super().invoke(ctx)

Send me your setup/custom questions, please, so I can try and replicate that somehow

Get me assigned, I'll take a look to this fuckery problems.

Okay, this was... stupid of me lol. Function _default_questions_string wasn't returning anything because I forgot to add return string there, it should work now.

Okay, this was... stupid of me lol. Function _default_questions_string wasn't returning anything because I forgot to add return string there, it should work now.

and finally, it works perfectly now haha. thanks for the fix