How should I Private DM my user after they send a command? (Discord Python)

Multi tool use
Multi tool use












0















I am coding a python discord program, and I'm very new to this. I tried a few answers to Private DMs, but none of them seemed to work. I can't tell if I am doing anything wrong. I would like any user/a user with a role to say a command, eg .gen and the bot sends dm.



My code:



import discord
import random
from discord.ext import commands
from random import randint

bot = commands.Bot(command_prefix='.', description='Generates accounts')
x=1
spotifynum = 0
spotifyvisnum = 1

with open("spotify.txt") as f:
spot = f.readlines()
spot = [x.strip() for x in spot]

with open("spotify.txt") as f:
spot = f.readlines()
spot = [x.strip() for x in spot]

@bot.event
async def on_ready():
print(("-")*40)
print('Logged in as')
print(bot.user.name)
print(("-")*40)

@bot.command()
async def hello():
await bot.say('Hello!')

@bot.command()
async def gen():
await ctx.author.send("hi")





bot.run('private_code')









share|improve this question





























    0















    I am coding a python discord program, and I'm very new to this. I tried a few answers to Private DMs, but none of them seemed to work. I can't tell if I am doing anything wrong. I would like any user/a user with a role to say a command, eg .gen and the bot sends dm.



    My code:



    import discord
    import random
    from discord.ext import commands
    from random import randint

    bot = commands.Bot(command_prefix='.', description='Generates accounts')
    x=1
    spotifynum = 0
    spotifyvisnum = 1

    with open("spotify.txt") as f:
    spot = f.readlines()
    spot = [x.strip() for x in spot]

    with open("spotify.txt") as f:
    spot = f.readlines()
    spot = [x.strip() for x in spot]

    @bot.event
    async def on_ready():
    print(("-")*40)
    print('Logged in as')
    print(bot.user.name)
    print(("-")*40)

    @bot.command()
    async def hello():
    await bot.say('Hello!')

    @bot.command()
    async def gen():
    await ctx.author.send("hi")





    bot.run('private_code')









    share|improve this question



























      0












      0








      0








      I am coding a python discord program, and I'm very new to this. I tried a few answers to Private DMs, but none of them seemed to work. I can't tell if I am doing anything wrong. I would like any user/a user with a role to say a command, eg .gen and the bot sends dm.



      My code:



      import discord
      import random
      from discord.ext import commands
      from random import randint

      bot = commands.Bot(command_prefix='.', description='Generates accounts')
      x=1
      spotifynum = 0
      spotifyvisnum = 1

      with open("spotify.txt") as f:
      spot = f.readlines()
      spot = [x.strip() for x in spot]

      with open("spotify.txt") as f:
      spot = f.readlines()
      spot = [x.strip() for x in spot]

      @bot.event
      async def on_ready():
      print(("-")*40)
      print('Logged in as')
      print(bot.user.name)
      print(("-")*40)

      @bot.command()
      async def hello():
      await bot.say('Hello!')

      @bot.command()
      async def gen():
      await ctx.author.send("hi")





      bot.run('private_code')









      share|improve this question
















      I am coding a python discord program, and I'm very new to this. I tried a few answers to Private DMs, but none of them seemed to work. I can't tell if I am doing anything wrong. I would like any user/a user with a role to say a command, eg .gen and the bot sends dm.



      My code:



      import discord
      import random
      from discord.ext import commands
      from random import randint

      bot = commands.Bot(command_prefix='.', description='Generates accounts')
      x=1
      spotifynum = 0
      spotifyvisnum = 1

      with open("spotify.txt") as f:
      spot = f.readlines()
      spot = [x.strip() for x in spot]

      with open("spotify.txt") as f:
      spot = f.readlines()
      spot = [x.strip() for x in spot]

      @bot.event
      async def on_ready():
      print(("-")*40)
      print('Logged in as')
      print(bot.user.name)
      print(("-")*40)

      @bot.command()
      async def hello():
      await bot.say('Hello!')

      @bot.command()
      async def gen():
      await ctx.author.send("hi")





      bot.run('private_code')






      python-3.x discord






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 13:07







      DMM Official

















      asked Dec 31 '18 at 11:53









      DMM OfficialDMM Official

      53




      53
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You are looking at the docs for rewrite, but probably using async code. You need to use await bot.send(dest, message) to send messages in async






          share|improve this answer
























          • what do I put where dest is???

            – DMM Official
            Jan 1 at 0:23











          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%2f53987180%2fhow-should-i-private-dm-my-user-after-they-send-a-command-discord-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You are looking at the docs for rewrite, but probably using async code. You need to use await bot.send(dest, message) to send messages in async






          share|improve this answer
























          • what do I put where dest is???

            – DMM Official
            Jan 1 at 0:23
















          0














          You are looking at the docs for rewrite, but probably using async code. You need to use await bot.send(dest, message) to send messages in async






          share|improve this answer
























          • what do I put where dest is???

            – DMM Official
            Jan 1 at 0:23














          0












          0








          0







          You are looking at the docs for rewrite, but probably using async code. You need to use await bot.send(dest, message) to send messages in async






          share|improve this answer













          You are looking at the docs for rewrite, but probably using async code. You need to use await bot.send(dest, message) to send messages in async







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 31 '18 at 18:20









          WayToDoorWayToDoor

          536317




          536317













          • what do I put where dest is???

            – DMM Official
            Jan 1 at 0:23



















          • what do I put where dest is???

            – DMM Official
            Jan 1 at 0:23

















          what do I put where dest is???

          – DMM Official
          Jan 1 at 0:23





          what do I put where dest is???

          – DMM Official
          Jan 1 at 0:23


















          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%2f53987180%2fhow-should-i-private-dm-my-user-after-they-send-a-command-discord-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







          1AlfDg1hHEy ui
          5VRq5nuwKe,q4TIf GeJZ12kHR1,6aK1KGv Tpp,QL0QaMX CWFoog,YzBvGipEwgM2yGW5V40,6baAv3xuu5U3W3XFYO

          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas