J.Lee
0
Q:

python discord

import discord

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run('your token here')
3
# To make a simple discord bot that when the message content is '.hello'
# first you need to create a bot on discord.com/developers/
#there are many tutorials on how to create a bot
# then use py -3 -m pip install -U discord.py[voice] in terminal
# or if you're on mac/linux python3 -m pip install -U discord.py[voice]
import discord.py

client = discord.Client()
@client.event
async def on_ready():
    print("Logged in as {0.user}".format(client)

@client.event
async def on_message(message):
      #this will prevent the bot from responding to itself
      if message.author == client.user:
      		return
      
      #now let's start with the message content check
      if message.content == '.hello':
          print("Hello there!!")
          
#now run the bot
client.run('here put your token')

#and now when you run the program the bot will be online and working
0
import discord

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run('your token here')
-1
import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')

client = MyClient()
client.run('token')
6
# discord.py is the package you are looking for if you want to make a discord bot using python.
# Install it by typing this in shell/bash:
pip install discord.py
0

New to Communities?

Join the community