Advertisement
Guest User

Python Discord Bot Code

a guest
Aug 20th, 2021
1,742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import discord
  2. import os # <------ don't use this if not using repl.it
  3. import requests # <------ don't use this if not using repl.it
  4. import json # <------ don't use this if not using repl.it
  5. import random # <------ don't use this if not using repl.it
  6. from replit import db # <------ don't use this if not using repl.it
  7.  
  8. client = discord.Client()
  9.  
  10. @client.event
  11. async def on_ready():
  12. print('bot is ready!')
  13.  
  14.  
  15. @client.event
  16. async def on_message(message):
  17. if message.author == client.user:
  18. return
  19.  
  20. msg = message.content
  21.  
  22. if msg.startswith('!ping'): #this is for the command
  23. await message.channel.send("pong") #bot respond
  24.  
  25. client.run(os.getenv('TOKEN')) #enter token in 'TOKEN'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement