Dataset Viewer
Auto-converted to Parquet Duplicate
input
stringclasses
5 values
output
stringclasses
5 values
Create a basic Discord bot using Nextcord.
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)
Add a ping command to my Nextcord bot.
# 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))
Create a slash command that says hello.
# 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))
Add a ban command to my Nextcord bot.
# 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))
Create a DM command using Nextcord.
# 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))
README.md exists but content is empty.
Downloads last month
21