I have tried some methods but none work. The code for my bot is under this.
`#testbot
GeneratedToken = "hidden"
import random
from random import randint
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
bot = commands.Bot(command_prefix="va-")
client = discord.Client()
@bot.event
async def on_ready():
print("READY")
print("ID: " + bot.user.id)
print("NAME: " + bot.user.name)
print("TOKEN: " + GeneratedToken)
await bot.change_presence(game=discord.Game(name="[1.2.5] - On github! bit.ly/vallegitbot"))
@bot.command(pass_context=True)
async def boti(ctx):
embed = discord.Embed(title="valle-bot info", description="Current version made 2018-03-23 (Version 1.2)", color=0x42e5f4)
embed.add_field(name="Made with :heart: in :flag_se: by VertaUser", value="Environment: discord.py")
await bot.say(embed=embed)
@bot.command(pass_context=True)
async def number(ctx):
embed = discord.Embed(title="Random number", description=randint(0,99999), color=0x42e5f4)
await bot.say(embed=embed)
@bot.command(pass_context=True)
async def useri(ctx, user: discord.Member):
embed = discord.Embed(title="Info about {}".format(user.name), description="I found this about {}".format(user.name), color=0x42e5f4)
embed.add_field(name="User ID", value=user.id, inline=True)
embed.add_field(name="User joindate", value=user.joined_at, inline=True)
embed.add_field(name="User status", value=user.status)
embed.add_field(name="User role", value=user.top_role, inline=True)
embed.set_thumbnail(url=user.avatar_url)
await bot.say(embed=embed)
@bot.command(pass_context=True)
async def rndnum(ctx):
embed = discord.Embed(title="Random number", description=randint(0,9999999), color=0x42e5f4)
await bot.say(embed=embed)
@bot.command(pass_context=True)
async def rndclr(ctx):
color = "%06x" % random.randint(0, 0xFFFFFF)
embed = discord.Embed(title="Random color", description=color)
await bot.say(embed=embed)
@bot.command(pass_context=True)
async def DMTesting(ctx, user: discord.Member):
await bot.send_message(ctx.message.author, 'Warning! Experimental nuclear testing!')
bot.run(GeneratedToken)
`
Providing a member/user object as a destination is the correct way to do it. It will error if they have DMs disabled or they do not share a server. What makes you think its not working?
Sidenote, your imports of randint and bot are pointless when you can (and do) just use random.randint and commands.bot to access the method.
Also,
Oh shit, you leaked your token!
In some way or another, you have just given your token away. This is not a good thing, as it gives anyone access to the user for that token! You can reset your token in a couple of ways:
For bot accounts: Go to your app page https://discordapp.com/developers/applications/me and generate a new token there.
For user accounts: Either change your password, or enable/disable 2fa. Either one will change your user token.
Your token is available in your github commit history.
Most helpful comment
Also,
Oh shit, you leaked your token!
In some way or another, you have just given your token away. This is not a good thing, as it gives anyone access to the user for that token! You can reset your token in a couple of ways:
For bot accounts: Go to your app page https://discordapp.com/developers/applications/me and generate a new token there.
For user accounts: Either change your password, or enable/disable 2fa. Either one will change your user token.
Your token is available in your github commit history.