Skip to content

noemtdev/auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage:

from noms.auth import setup
setup() # do this once only

import discord
from discord.ext import commands
from noms.auth import Auth

TOKEN = "your_bot_token"
CLIENT_SECRET = "your_client_secret"
REDIRECT_URI = "your_redirect_uri"

intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)


@bot.event
async def on_ready():
    print(f"Logged in as {bot.user.name}")
    print("Bot is ready to use!")
    auth_instance = Auth(bot, CLIENT_SECRET, REDIRECT_URI, TOKEN, "0.0.0.0", 8080)


@bot.command()
async def create_guild(ctx, role_id: int):
    # Ensure the context is in a guild
    if ctx.guild:
        access_token = await auth_instance.create_guild(ctx.guild, role_id)
        await ctx.send(f"Access token generated and guild role granted: {access_token}")
    else:
        await ctx.send("This command can only be used in a guild.")

@bot.command()
async def login_url(ctx, guild_id: int):
    login_url = auth_instance.create_url(guild_id)
    await ctx.send(f"Login URL for Guild {guild_id}: {login_url}")

bot.run(TOKEN)

Keep in mind that the code sample was generated by ChatGPT because I am too lazy..

Releases

No releases published

Packages

No packages published

Languages