discord.py get message code example
Example 1: discord bot status python
await bot.change_presence(activity=discord.Game(name="a game"))
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
Example 2: send message discord.py
await message.channel.send("Your message")
Example 3: discord.py message user
if message.content == "dm":
await message.channel.send("Dming user")
dm = await message.author.create_dm()
await dm.send("What you want to send")
Example 4: 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')
Example 5: discord py server.channels
bot.get_all_channels()