tagscas.blogg.se

Discord bots to add to your server
Discord bots to add to your server









When the user signs in, get their token

discord bots to add to your server

Configure one or more authentication providersĬlientId: _ID as string,ĬlientSecret: _SECRET as string, Import DiscordProvider from "next-auth/providers/discord"

discord bots to add to your server

Now let's make our API route look like this: import NextAuth from "next-auth" We also need to add a Redirect URL into our Application while we're here: env.local file at the root of the directory. This is where we'll configure our NextAuth setup and allow people to sign in to our application using Discord.īack in your Discord Developer Portal, copy across your Client ID and Client Secret into environment variables in your project, by creating a. To authenticate users with Discord, we'll be using the library ` NextAuthĬreate a new folder inside of pages called api, and within that, create another folder called auth, and within this auth folder, create a file called. It will ask you to approve this bot's permissions, you should see a prompt to authorize the bot for Manage Roles permissions:Ĭlick Authorise, once successful, you'll see an Authorised windowĪnd your bot will be added to your server - say hi! Authenticating Users Make sure it is the bot you expect, select the server you want to add your bot to and click Continue. Now we're ready to invite our bot to our server!Ĭlick OAuth2 > URL Generator on the sidebar:Ĭopy the Generated URL and open it in your browser. If your bot token is compromised, other users can perform any actions you have permitted it to do. It's important to note that you should only give your bot the roles it requires. Scroll down to Bot Permissions and give our bot the Manage Roles permission: Give your bot a username, and I'm unchecking the Public Bot field so that only we can invite our bot. Once it's created, head to the Bot tab, and click Add Bot. To create a Discord bot, head to the Discord Developer Portal and click on New Application, give it a name and click create! If you don't have one, go ahead and create one now and come back to this guide, because next up, we'll create a bot and invite it to our server! Creating A Discord Bot We'll be using TypeScript and Next.js for this guide so give your app a name and select Next.js for the framework, and TypeScript for the language.įor this guide, we'll assume you already have a Discord server created and a role set up in the server.

discord bots to add to your server

To get started, we can use the thirdweb CLI npx create app Similar to Collab.Land, we'll ask the user to sign in with their wallet as well as their Discord account on our web application, and ask a bot we create to grant them a role on our server using the Discord API running on a Next.js API route.

discord bots to add to your server

In this guide, we'll set up a Discord bot that checks if a wallet has an NFT from a collection, and grants them a special role on our Discord server if they do!











Discord bots to add to your server