user72427
0
Q:

discord.py

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
from discord.ext import commands

client=commands.Bot(command_prefix="your bot's prefix")

@client.event
async def on_ready():
  print("I am online")

@client.command()
async def ping(ctx):
  await ctx.send(f"Pong! {client.latency}")

client.run('Your Token')
4
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

New to Communities?

Join the community