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

Multi tool use
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
add a comment |
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
add a comment |
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
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
python-3.x discord
edited Dec 31 '18 at 13:07
DMM Official
asked Dec 31 '18 at 11:53


DMM OfficialDMM Official
53
53
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
what do I put where dest is???
– DMM Official
Jan 1 at 0:23
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%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
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
what do I put where dest is???
– DMM Official
Jan 1 at 0:23
add a comment |
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
what do I put where dest is???
– DMM Official
Jan 1 at 0:23
add a comment |
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
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
answered Dec 31 '18 at 18:20
WayToDoorWayToDoor
536317
536317
what do I put where dest is???
– DMM Official
Jan 1 at 0:23
add a comment |
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
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%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
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
1AlfDg1hHEy ui