Answers for "write discord bots in python"

14

bot discord python

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!", description="The description")

@bot.event
async def  on_ready():
    print("Ready !")

@bot.command()
async def ping(ctx):
    await ctx.send('**pong**')

bot.run("enter the token here between the quotes")
Posted by: Guest on January-02-2021
0

discord python application bot

q_list = [
    'What is your favorite color?',
    'Is the Sky Blue?',
    'Am I the best bot ever?'
]

a_list = []


@client.command(aliases=['staff-application'])
async def staff_application(ctx):
    a_list = []
    submit_channel = client.get_channel(<your channel id>)
    channel = await ctx.author.create_dm()

    def check(m):
        return m.content is not None and m.channel == channel

    for question in q_list:
        sleep(.5)
        await channel.send(question)
        msg = await client.wait_for('message', check=check)
        a_list.append(msg.content)

    submit_wait = True
    while submit_wait:
        await channel.send('End of questions - "submit" to finish')
        msg = await client.wait_for('message', check=check)
        if "submit" in msg.content.lower():
            submit_wait = False
            answers = "n".join(f'{a}. {b}' for a, b in enumerate(a_list, 1))
            submit_msg = f'Application from {msg.author} nThe answers are:n{answers}'
            await submit_channel.send(submit_msg)
Posted by: Guest on May-19-2021

Python Answers by Framework

Browse Popular Code Answers by Language