input: Create a basic Discord bot using Nextcord.

output:
import nextcord
from nextcord.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

intents = nextcord.Intents.default()
bot = commands.Bot(command_prefix='!', intents=intents)

# Load cogs
bot.load_extension('cogs.ping')
bot.load_extension('cogs.hello')

@bot.event
async def on_ready():
    print(f'Bot connected as {bot.user}')

bot.run(TOKEN)


input: Add a ping command to my Nextcord bot.

output:
# cogs/ping.py
from nextcord.ext import commands

class Ping(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def ping(self, ctx):
        await ctx.send('Pong!')

def setup(bot):
    bot.add_cog(Ping(bot))


input: Create a slash command that says hello.

output:
# cogs/hello.py
from nextcord.ext import commands
import nextcord

class Hello(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @nextcord.slash_command(name="hello", description="Say hello")
    async def hello(self, interaction: nextcord.Interaction):
        await interaction.response.send_message("Hello!")

def setup(bot):
    bot.add_cog(Hello(bot))


input: Add a ban command to my Nextcord bot.

output:
# cogs/ban.py
from nextcord.ext import commands
import nextcord

class Ban(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def ban(self, ctx, member: nextcord.Member, *, reason=None):
        await member.ban(reason=reason)
        await ctx.send(f'{member} has been banned.')

def setup(bot):
    bot.add_cog(Ban(bot))


input: Create a DM command using Nextcord.

output:
# cogs/dm.py
from nextcord.ext import commands
import nextcord

class DM(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def dm(self, ctx, member: nextcord.Member, *, message):
        await member.send(message)
        await ctx.send(f'Message sent to {member.display_name}')

def setup(bot):
    bot.add_cog(DM(bot))