Starting Up
Now, go on LINK here and login, then make a new app. Name it whatever you want. Once you have made the application, you need to scroll down and create a Bot User. Now you have made a bot, you are going to need to use the token. NOTE: DO NOT TELL ANYONE YOUR TOKEN.
Now, open a python and import all this:
---------------------------------------
import discord
import asyncio
import random
import youtube_dl
from discord.ext import commands
from discord.ext.commands import Bot
----------------------------------------
and save it.
Now we are going to make our lives easier and make a shortcut for 'discord.Client()'. So 'Client = discord.Client()' We are also going to make a prefix for the bot. So we do 'bot_prefix = "(Anything you want eg: $ without these brackets.)" and for the end do
'client = commands.Bot(command_prefix=bot_prefix)'
If you will want to make your own help command then do the following: 'client.remove_command('help')' This will remove the original help command which shows all commands you have made.
Another thing which you have to do is:
@client.event
async def on_ready():
print("Logged in as")
print(client.user.name + " (" + client.user.id + ")" )
Now for the last thing you have to do is write this at the end of everything:
client.run('Token')
You should be able to get your token from your app User Bot. Should look something like this.
'print(client.user.name + " (" + client.user.id + ")" )'
This prints the bots name and id into the python shell. Now save and F5 to run it.
However, you might not acctually know if it worked. To see if it worked you need to add your bot to a discord server. https://discordapp.com/oauth2/authorize?&client_id=YYYY&scope=bot you need to change the 'Y' to your discord bot id.
Then choose your discord server and click 'authorised'
Once you invite him your bot has joined, run your bot again.
You should see it be online if not, your doing something wrong. If so and your getting an error post it in the comments. Our first command will be very simple. You say ping. The bot then response and says Pong! We are going to have to call the client and the command. So it should look like this:
@client.command(pass_context=True)
We are going to have to make it as a def. Like this:
async def ping(ctx):
Where it says ping, it will make it so when you do (prefix)ping the bot will see it and say Pong! But now we have to make him say that when you say ping/ So:
await client.say("Ping!")
'Await' is a coroutine and its only used within a async def. Should look something like this.
Save it (Crtl+S) and run it(F5)!
Well done! You have just made a simple command!












Comments
Post a Comment