Answer the question
In order to leave comments, you need to log in
Who can help with discord.py?
I want to post a random phrase from the list, but an error pops up in the console. WHERE IS THE ERROR?!
import discord
from discord.ext import commands
import sqlite3
import random
import time
iq = ["a", "b", "c"] #создаём список со случайными фразами для команды !iq
bot = commands.Bot(command_prefix=('!')) #префикс нашего бота
bot.remove_command( 'help' ) #удаляем базовую команду help
TOKEN = "" #заносим токен бота в переменную
@bot.command()
async def iq(ctx):
global iq
await ctx.send('сканирую...')
time.sleep(1)
a = random.choice(iq)
await ctx.send(a)
bot.run(TOKEN)
Answer the question
In order to leave comments, you need to log in
at least you can do it like this:
import random
@bot.command()
async def iq(ctx):
words = ['фраза один', 'фраза два...']
await ctx.send(random.choice(words))
You have two variables named the same (function/command and list).
import asyncio
import discord
from discord.ext import commands
import sqlite3
import random
bot = commands.Bot(command_prefix=('!'))
bot.remove_command( 'help' )
TOKEN = ""
IQ_PHRASES = ["a", "b", "c"]
@bot.command()
async def iq(ctx):
await ctx.send('сканирую...')
await asyncio.sleep(1)
a = random.choice(IQ_PHRASES)
await ctx.send(a)
bot.run(TOKEN)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question