File size: 2,243 Bytes
79ec0de
 
 
 
 
1
2
3
4
5
{"input": "Create a basic Discord bot using Nextcord.", "output": "import nextcord\nfrom nextcord.ext import commands\nimport os\nfrom dotenv import load_dotenv\n\nload_dotenv()\nTOKEN = os.getenv('DISCORD_TOKEN')\n\nintents = nextcord.Intents.default()\nbot = commands.Bot(command_prefix='!', intents=intents)\n\n# Load cogs\nbot.load_extension('cogs.ping')\nbot.load_extension('cogs.hello')\n\n@bot.event\nasync def on_ready():\n    print(f'Bot connected as {bot.user}')\n\nbot.run(TOKEN)"}
{"input": "Add a ping command to my Nextcord bot.", "output": "# cogs/ping.py\nfrom nextcord.ext import commands\n\nclass Ping(commands.Cog):\n    def __init__(self, bot):\n        self.bot = bot\n\n    @commands.command()\n    async def ping(self, ctx):\n        await ctx.send('Pong!')\n\ndef setup(bot):\n    bot.add_cog(Ping(bot))"}
{"input": "Create a slash command that says hello.", "output": "# cogs/hello.py\nfrom nextcord.ext import commands\nimport nextcord\n\nclass Hello(commands.Cog):\n    def __init__(self, bot):\n        self.bot = bot\n\n    @nextcord.slash_command(name=\"hello\", description=\"Say hello\")\n    async def hello(self, interaction: nextcord.Interaction):\n        await interaction.response.send_message(\"Hello!\")\n\ndef setup(bot):\n    bot.add_cog(Hello(bot))"}
{"input": "Add a ban command to my Nextcord bot.", "output": "# cogs/ban.py\nfrom nextcord.ext import commands\nimport nextcord\n\nclass Ban(commands.Cog):\n    def __init__(self, bot):\n        self.bot = bot\n\n    @commands.command()\n    @commands.has_permissions(ban_members=True)\n    async def ban(self, ctx, member: nextcord.Member, *, reason=None):\n        await member.ban(reason=reason)\n        await ctx.send(f'{member} has been banned.')\n\ndef setup(bot):\n    bot.add_cog(Ban(bot))"}
{"input": "Create a DM command using Nextcord.", "output": "# cogs/dm.py\nfrom nextcord.ext import commands\nimport nextcord\n\nclass DM(commands.Cog):\n    def __init__(self, bot):\n        self.bot = bot\n\n    @commands.command()\n    async def dm(self, ctx, member: nextcord.Member, *, message):\n        await member.send(message)\n        await ctx.send(f'Message sent to {member.display_name}')\n\ndef setup(bot):\n    bot.add_cog(DM(bot))"}