Answers for "How to make server info command in discord.py"

2

discord.py basic command

#If you havent already install discord.py using pip install discord.py
#Then import discord
#Then Import commands
import discord
from discord.ext import commands
#Create your bot instinct
#With the bot Prefix set to !
#You can change it to your choice
client = commands.Bot(command_prefix='!')
client.remove_command('help')
#This is an event when the bot logs in this help to check if 
#the bot is running correctly
@client.event
async def on_ready():
    print('Logged on as Stars Bot')
#This is a basic commad that returns the bots ping
@client.command()
async def ping(ctx):
    await ctx.send(f'Ping is `{round(client.latency * 1000)}` ms ')
#Change the Your token here with the token found in your discord developer portal
#https://discord.com/developers/applications here is a link 
client.run('Your Token here')
Posted by: Guest on July-12-2021
4

command handler discord.py

for file in os.listdir("./cogs"): # lists all the cog files inside the cog folder.
    if file.endswith(".py"): # It gets all the cogs that ends with a ".py".
        name = file[:-3] # It gets the name of the file removing the ".py"
        bot.load_extension(f"cogs.{name}") # This loads the cog.
Posted by: Guest on July-03-2021

Code answers related to "How to make server info command in discord.py"

Python Answers by Framework

Browse Popular Code Answers by Language