Back to Browse

Assigning Roles with Buttons - Python Discord Bot Tutorial

21.6K views
Sep 3, 2021
14:33

How to add button components for role assignments to your Python Discord bot with Nextcord. ❤ Subscribe: http://bit.ly/SubscribeDPT In this video, I will be using the Nextcord fork of Discord.py to make button components that correspond to roles that will be assigned to the user when they click them. This is similar to the old way of doing reaction roles, but this time, we can use real buttons! The buttons used in this video are persistent, meaning they do not timeout and will continue working even if the bot restarts. ❗Note: The on_ready event listener may run multiple times. At 8:00 in the video, you can modify the function to avoid adding the view multiple times by checking if it has already been added using a variable on the bot. (See https://github.com/nextcord/nextcord/blob/master/examples/views/persistent.py for an example) 👨‍💻 Source Code https://github.com/DenverCoder1/dev-pro-tips-bot/tree/e8ce045c31725d84238aabf654cc28f144fb8f6d/cogs/button_roles 💬 Dev Pro Tips Discussion & Support Server https://discord.gg/fPrdqh3Zfu 📜 Nextcord Documentation https://nextcord.readthedocs.io/en/latest 🗨 Nextcord Server https://discord.gg/ZebatWssCB 📓 Python Discord Bot Template https://github.com/DenverCoder1/discord-bot-template 📺 In this video: 0:00​ - Introduction 0:35 - Nextcord examples 0:58 - Setting up Buttons 10:28 - Assigning roles 13:51 - Conclusion In future videos in this series, I plan to show you how you can: * Implement selects, and other Discord components * Implement slash commands * Welcome users * Interact with other APIs to make useful bot features * Much more Make sure to subscribe so you don't miss anything! 🐍 More Discord Bot Tutorials https://youtube.com/playlist?list=PL9YUC9AZJGFG6larkQJYio_f0V-O1NRjy 💻 More tutorials https://www.youtube.com/playlist?list=PL9YUC9AZJGFHTUP3vzq4UfQ76ScBnOi-9 🙋‍♂️ Find me on other channels Discord 🗨️ https://bit.ly/dpt-discord Twitter ✍ https://twitter.com/DenverCoder1 Github 👨‍💻 https://github.com/DenverCoder1 Sponsor 💞 https://github.com/sponsors/DenverCoder1 Buy me a coffee ☕ https://ko-fi.com/jlawrence 💖 SPONSORS 💖 Get your username or a link to your channel here by sponsoring on GitHub ▶ https://github.com/sponsors/DenverCoder1​ 🎁 GET FREE STUFF WHILE SUPPORTING MY TUTORIALS ► https://bit.ly/jlawrencepromos

Download

0 formats

No download links available.

Assigning Roles with Buttons - Python Discord Bot Tutorial | NatokHD