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)













1















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!










share|improve this question
























  • 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















1















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!










share|improve this question
























  • 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













1












1








1








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!










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












2 Answers
2






active

oldest

votes


















1














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.






share|improve this answer






























    1














    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.






    share|improve this answer

























      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
      );



      );













      draft saved

      draft discarded


















      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









      1














      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.






      share|improve this answer



























        1














        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.






        share|improve this answer

























          1












          1








          1







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 20:34









          Adam SmithAdam Smith

          35.3k73376




          35.3k73376























              1














              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.






              share|improve this answer





























                1














                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.






                share|improve this answer



























                  1












                  1








                  1







                  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.






                  share|improve this answer















                  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.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 8 at 20:59

























                  answered Mar 8 at 20:52









                  MaryMary

                  614




                  614



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                      Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                      How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page