“sistema de bienvenida” Código de respuesta

sistema de bienvenida

import json

#sets value in json to guild id upon the bot joining the guild
@client.event
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("filename.json", "w" as f:
        json.dump(guildInfo, f)

#allows server members to set channel for welcome messages to send to    
@client.command()
async def welcomeMessage(ctx):
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[ctx.message.guild.id] = ctx.message.channel.id #sets channel to send message to as the channel the command was sent to

    with open("filename.json", "w") as f:
        json.dump(guildInfo, f)


sistema de bienvenida

import json

#sets value in json to guild id upon the bot joining the guild
@client.event
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("filename.json", "w" as f:
        json.dump(guildInfo, f)

#allows server members to set channel for welcome messages to send to    
@client.command()
async def welcomeMessage(ctx):
    with open("filename.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[ctx.message.guild.id] = ctx.message.channel.id #sets channel to send message to as the channel the command was sent to

    with open("filename.json", "w") as f:
        json.dump(guildInfo, f)


Respuestas similares a “sistema de bienvenida”

Preguntas similares a “sistema de bienvenida”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código