I
I
iproyt2021-11-04 19:04:08
Python
iproyt, 2021-11-04 19:04:08

How to implement this in discord.py?

In short, I know the question is stupid, but help me, I'm just a beginner
, how to make the code where the random is activated again when writing the command, please tell me
here is the code:

import random
from random import randint
import discord
from discord.ext import commands
prefix = "."
bot = commands.Bot(command_prefix = prefix)

#random

rand3 = ["Добрый мишка -- Секретный","Мишка с мишонкой -- Секретный"]
rand2 = ["Обычный мишка - обычный", "Мишка на стуле с шипами - Редкий", "Мишка без мишки - обычный"]
rand1 = ["Мишка сидит и ест мишку - Эпик", "Мишка смотртит хентай - Легендарный", "Мишка сидит на бебре - мифичисекий","Злой мишка -- Легендарный","Белый миша -- Невозможный","мишка ест мороженое -- Легенадрный", "Мишка с мишонкой -- Секретный"]

r = (random.randint(1,1000))
if r <= 500:
    randc = (random.choice(rand2))
elif r >= 800:
    randc = (random.choice(rand1))
elif r <= 950:
    print(random.choice(rand3))


#bot

@bot.event
async def on_ready():
    print("The bot is ready!")

@bot.command(pass_context = True)
async def Mishka(ctx):
    await ctx.send(randc)

Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
seira-code, 2021-11-06
@iproyt

import random
from random import randint
import discord
from discord.ext import commands
prefix = "."
bot = commands.Bot(command_prefix = prefix)

#bot

@bot.event
async def on_ready():
    print("The bot is ready!")

@bot.command(pass_context = True)
async def Mishka(ctx):
    rand3 = ["Добрый мишка -- Секретный","Мишка с мишонкой -- Секретный"]
    rand2 = ["Обычный мишка - обычный", "Мишка на стуле с шипами - Редкий", "Мишка без мишки - обычный"]
    rand1 = ["Мишка сидит и ест мишку - Эпик", "Мишка смотртит хентай - Легендарный", "Мишка сидит на бебре - мифичисекий","Злой мишка -- Легендарный","Белый миша -- Невозможный","мишка ест мороженое -- Легенадрный", "Мишка с мишонкой -- Секретный"]

    r = (random.randint(1,1000))
    if r <= 500:
        randc = (random.choice(rand2))
    elif r >= 800:
        randc = (random.choice(rand1))
    elif r <= 950:
        print(random.choice(rand3))
    await ctx.send(randc)

V
Vindicar, 2021-11-04
@Vindicar

Ah simple same task, on logic.
When you enter a command, the Mishka () function works out, and you generate a random variant outside of it, once.
Bring random generation inside, and you will be happy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question