Print a variable output in a 400 empty message code using PythonHow to flush output of print function?How to print to stderr in Python?I cannot make bot join discord voice channels using the python discord modulediscord and bot making: i cant seem to get my bot to post a web parsed materialImporting tensorflow not working when upgradedDiscord.py Bot Not Leaving Voice ChannelI use asynchronous and requests and urllib are blockingFailed to establish a new connection Discord.pyError give role when a user add reaction Discord.pydiscord bot autorole — in _run_event yield from getattr(self, event)(*args, **kwargs)
Different meanings of こわい
What does the same-ish mean?
Blending or harmonizing
Why are UK visa biometrics appointments suspended at USCIS Application Support Centers?
How to coordinate airplane tickets?
Does int main() need a declaration on C++?
What's the meaning of "Sollensaussagen"?
What is an equivalently powerful replacement spell for the Yuan-Ti's Suggestion spell?
In Bayesian inference, why are some terms dropped from the posterior predictive?
Why do I get negative height?
How dangerous is XSS
Why is the sentence "Das ist eine Nase" correct?
What is required to make GPS signals available indoors?
Do creatures with a listed speed of "0 ft., fly 30 ft. (hover)" ever touch the ground?
Forgetting the musical notes while performing in concert
How can a day be of 24 hours?
Convert seconds to minutes
How to remove border from elements in the last row?
how do we prove that a sum of two periods is still a period?
How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?
How to stretch the corners of this image so that it looks like a perfect rectangle?
Is there a hemisphere-neutral way of specifying a season?
files created then deleted at every second in tmp directory
Getting extremely large arrows with tikzcd
Print a variable output in a 400 empty message code using Python
How to flush output of print function?How to print to stderr in Python?I cannot make bot join discord voice channels using the python discord modulediscord and bot making: i cant seem to get my bot to post a web parsed materialImporting tensorflow not working when upgradedDiscord.py Bot Not Leaving Voice ChannelI use asynchronous and requests and urllib are blockingFailed to establish a new connection Discord.pyError give role when a user add reaction Discord.pydiscord bot autorole — in _run_event yield from getattr(self, event)(*args, **kwargs)
Problem:
I am trying to code a bot for Discord so that to take a variable and send that as a message. For example, "a" is set to 42 and I want the bot to print in chat "The number is 42 author name":
a = 32
if message.content.startswith('!gap'):
msg = print('a'.format(message))
await client.send_message(message.channel, msg)
Error:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:UserstrevoDesktopdcbotreply.py", line 16, in on_message
await client.send_message(message.channel, msg)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 1152, in send_message
data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordhttp.py", line 200, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400): Cannot send an empty message
I appreciate explanations!
python discord discord.py bad-request
add a comment |
Problem:
I am trying to code a bot for Discord so that to take a variable and send that as a message. For example, "a" is set to 42 and I want the bot to print in chat "The number is 42 author name":
a = 32
if message.content.startswith('!gap'):
msg = print('a'.format(message))
await client.send_message(message.channel, msg)
Error:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:UserstrevoDesktopdcbotreply.py", line 16, in on_message
await client.send_message(message.channel, msg)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 1152, in send_message
data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordhttp.py", line 200, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400): Cannot send an empty message
I appreciate explanations!
python discord discord.py bad-request
Are you aware that'a'.format(message)
will just return'a'
?
– Mike Holt
Mar 8 at 20:37
Yes, I realized that but right now I am just trying to use print as a message.
– TrevTV
Mar 8 at 20:38
add a comment |
Problem:
I am trying to code a bot for Discord so that to take a variable and send that as a message. For example, "a" is set to 42 and I want the bot to print in chat "The number is 42 author name":
a = 32
if message.content.startswith('!gap'):
msg = print('a'.format(message))
await client.send_message(message.channel, msg)
Error:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:UserstrevoDesktopdcbotreply.py", line 16, in on_message
await client.send_message(message.channel, msg)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 1152, in send_message
data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordhttp.py", line 200, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400): Cannot send an empty message
I appreciate explanations!
python discord discord.py bad-request
Problem:
I am trying to code a bot for Discord so that to take a variable and send that as a message. For example, "a" is set to 42 and I want the bot to print in chat "The number is 42 author name":
a = 32
if message.content.startswith('!gap'):
msg = print('a'.format(message))
await client.send_message(message.channel, msg)
Error:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:UserstrevoDesktopdcbotreply.py", line 16, in on_message
await client.send_message(message.channel, msg)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 1152, in send_message
data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
File "C:UserstrevoAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordhttp.py", line 200, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400): Cannot send an empty message
I appreciate explanations!
python discord discord.py bad-request
python discord discord.py bad-request
edited Mar 8 at 21:30
Emma
1,1231920
1,1231920
asked Mar 8 at 20:31
TrevTVTrevTV
85
85
Are you aware that'a'.format(message)
will just return'a'
?
– Mike Holt
Mar 8 at 20:37
Yes, I realized that but right now I am just trying to use print as a message.
– TrevTV
Mar 8 at 20:38
add a comment |
Are you aware that'a'.format(message)
will just return'a'
?
– Mike Holt
Mar 8 at 20:37
Yes, I realized that but right now I am just trying to use print as a message.
– TrevTV
Mar 8 at 20:38
Are you aware that
'a'.format(message)
will just return 'a'
?– Mike Holt
Mar 8 at 20:37
Are you aware that
'a'.format(message)
will just return 'a'
?– Mike Holt
Mar 8 at 20:37
Yes, I realized that but right now I am just trying to use print as a message.
– TrevTV
Mar 8 at 20:38
Yes, I realized that but right now I am just trying to use print as a message.
– TrevTV
Mar 8 at 20:38
add a comment |
2 Answers
2
active
oldest
votes
You expect msg
to be a string, but if you try it:
>>> msg = print("anything at all")
>>> repr(msg)
None
Just remove the print
call.
add a comment |
You should not be using the on_message event to make commands. Use the built-in command handler instead which makes for better program design and efficiency.
The following code outputs the number you type after !gap
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command(pass_context=True)
async def gap(ctx, number):
await client.say(f"ctx.author.mention said the number number")
client.run("token")
I also recommend looking into the rewrite branch of the API which has a lot of improvements.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070583%2fprint-a-variable-output-in-a-400-empty-message-code-using-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You expect msg
to be a string, but if you try it:
>>> msg = print("anything at all")
>>> repr(msg)
None
Just remove the print
call.
add a comment |
You expect msg
to be a string, but if you try it:
>>> msg = print("anything at all")
>>> repr(msg)
None
Just remove the print
call.
add a comment |
You expect msg
to be a string, but if you try it:
>>> msg = print("anything at all")
>>> repr(msg)
None
Just remove the print
call.
You expect msg
to be a string, but if you try it:
>>> msg = print("anything at all")
>>> repr(msg)
None
Just remove the print
call.
answered Mar 8 at 20:34
Adam SmithAdam Smith
35.3k73376
35.3k73376
add a comment |
add a comment |
You should not be using the on_message event to make commands. Use the built-in command handler instead which makes for better program design and efficiency.
The following code outputs the number you type after !gap
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command(pass_context=True)
async def gap(ctx, number):
await client.say(f"ctx.author.mention said the number number")
client.run("token")
I also recommend looking into the rewrite branch of the API which has a lot of improvements.
add a comment |
You should not be using the on_message event to make commands. Use the built-in command handler instead which makes for better program design and efficiency.
The following code outputs the number you type after !gap
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command(pass_context=True)
async def gap(ctx, number):
await client.say(f"ctx.author.mention said the number number")
client.run("token")
I also recommend looking into the rewrite branch of the API which has a lot of improvements.
add a comment |
You should not be using the on_message event to make commands. Use the built-in command handler instead which makes for better program design and efficiency.
The following code outputs the number you type after !gap
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command(pass_context=True)
async def gap(ctx, number):
await client.say(f"ctx.author.mention said the number number")
client.run("token")
I also recommend looking into the rewrite branch of the API which has a lot of improvements.
You should not be using the on_message event to make commands. Use the built-in command handler instead which makes for better program design and efficiency.
The following code outputs the number you type after !gap
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.command(pass_context=True)
async def gap(ctx, number):
await client.say(f"ctx.author.mention said the number number")
client.run("token")
I also recommend looking into the rewrite branch of the API which has a lot of improvements.
edited Mar 8 at 20:59
answered Mar 8 at 20:52
MaryMary
614
614
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070583%2fprint-a-variable-output-in-a-400-empty-message-code-using-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you aware that
'a'.format(message)
will just return'a'
?– Mike Holt
Mar 8 at 20:37
Yes, I realized that but right now I am just trying to use print as a message.
– TrevTV
Mar 8 at 20:38