RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-369890

L0veLy's questions

Martin Hope
L0veLy
Asked: 2020-05-14 19:20:54 +0000 UTC

嵌入的奇怪错误

  • 0

我决定在一个不和谐的机器人中创建一个测验。一个人在服务器上输入一个命令,机器人就会通过私人信息向他发送问题。代码抛出 SyntaxError: invalid syntax 错误,引用 embed.add_field 行。需要修复什么?

@client.command()
async def викторина(ctx):
    await ctx.message.delete()
    await ctx.author.send(
        embed=discord.Embed(title='** ВИКТОРИНА "название" **', color=0x0080ff)
        embed.add_field(name='Автор **имя**')
        embed.set_footer(text='При нахождении багов, пишите **ссылка**')

        )
discord-py
  • 1 个回答
  • 10 Views
Martin Hope
L0veLy
Asked: 2020-05-07 04:01:38 +0000 UTC

我不明白为什么不和谐机器人不起作用

  • 0

我将网上的几个代码合二为一,用于我的discord bot,从所有功能(信息板,游戏状态,登录消息,彩虹角色,只有彩虹角色有效。没有错误出来,我不明白需要什么被改变。

import discord
from discord import utils
from discord.ext import commands
import asyncio
import random
import os

token = 'token'
serverid = id

client = commands.Bot( command_prefix = '.')
client.remove_command( 'help' )
PREFIX = "."

# Табличка с информацией

@client.command()
async def info(ctx):
    print('Табличка с инфой работает')
    embed=discord.Embed(title="ПИ-БОТ", description="Бот для ПИ-18(9)", color=0x0080ff)

    embed.add_field(name="Cоздатель:", value="name", inline=True)
    embed.add_field(name="Версия:", value="1", inline=True)
    embed.set_thumbnail(url = 'url')
    embed.set_footer(text="Бот")

    await ctx.send(embed=embed)

# Игровой статус

@client.event
async def ready():
    print( 'Игровой статус работает' )
    await client.change_presence( status = discord.Status.online, activity = discord.Game( 'game'  ) )

#Сообщение о том, что Юзер зашёл на сервер + выдача роли
@client.event
async def on_member_join( member ):
    print('Приветственное сообщение работает')
    emb = discord.Embed( description = f"**{member.mention}** зашел на сервер, добро пожаловать!", color = 0x0c0c0c )
    role = discord.utils.get( member.guild.roles, id = id ) # Айди роли, которая будет выдаваться, когда человек зашёл на сервер

    await member.add_roles( role )
    channel = client.get_channel( id ) # Айди канала, куда будет писаться сообщение
    await channel.send( embed = emb ) 

# Радужная роль

client = discord.Client()
colours = [discord.Color.dark_orange(),discord.Color.orange(),discord.Color.dark_gold(),discord.Color.gold(),discord.Color.dark_magenta(),discord.Color.magenta(),discord.Color.red(),discord.Color.dark_red(),discord.Color.blue(),discord.Color.dark_blue(),discord.Color.teal(),discord.Color.dark_teal(),discord.Color.green(),discord.Color.dark_green(),discord.Color.purple(),discord.Color.dark_purple()]
rainbowrolename = "name"
delay = 5

@client.event
async def rainbowrole(role):
    for role in client.get_guild(serverid).roles:
        if str(role) == str(rainbowrolename):
            while not client.is_closed():
                try:
                    await role.edit(color=random.choice(colours))
                except Exception:
                    print("can't edit role, make sure the bot role is above the rainbow role and that is have the perms to edit roles")
                    pass
                await asyncio.sleep(delay)
    print('role with the name "' + rainbowrolename +'" not found')
    print("creating the role...")
    try:
        await client.get_guild(serverid).create_role(reason="Created rainbow role", name=rainbowrolename)
        print("role created!")
        await asyncio.sleep(2)
        client.loop.create_task(rainbowrole(rainbowrolename))
    except Exception as e:
        print("couldn't create the role. Make sure the bot have the perms to edit roles")
        print(e)
        pass
        await asyncio.sleep(10)
        client.loop.create_task(rainbowrole(rainbowrolename))  

@client.event
async def on_ready():
    client.loop.create_task(rainbowrole(rainbowrolename))
    print('Радужная роль работает')     

client.run(token)
python
  • 2 个回答
  • 10 Views
Martin Hope
L0veLy
Asked: 2020-01-30 21:14:45 +0000 UTC

在python界面中触发按钮

  • 0

我创建了一个界面形式的测验,但后来我想出了在中心制作START按钮的想法,按下时会跳转到主代码,但我不知道如何制作按下按钮的触发器。我试着按照网上的指南添加它,但没有任何改变,他立即打开一个窗口提出问题。也许我只是愚蠢,我很乐意提供帮助)

from tkinter import *
from tkinter import messagebox

root = Tk()
root.title('Викторина')
root.geometry('600x600')
root["bg"] = "#6C48D7"

# Кнопка START (que_zero) тут, запускающая que_one

def que_one():
    question = Label(root, text='Тут будет вопрос', font='20', fg='#000000', bg='#FFD673')
    question_2 = Label(root, text='Введи ответ цифрой: ', font='15', fg='#000000')
    answer = Entry(bg='#C0C0C0')
    btn = Button(root, text='Ответить', command=lambda: game1(que_two))
    btn.grid(row = 0)
    btn.place(relx=.5, rely=.8, anchor="c", height=60, width=500, bordermode=OUTSIDE)
    question_3 = Label(root, text='1. Тут будет ответ', font='15', bg='#FF4040', fg='#FFFFFF')
    question_4 = Label(root, text='2. Тут будет ответ', font='15', bg='#FF4040', fg='#FFFFFF')
    question_5 = Label(root, text='3. Тут будет ответ', font='15', bg='#FF4040', fg='#FFFFFF')
    question_6 = Label(root, text='Правильных ответов: 0', font='5', bg='#FFD700')
    question_6.place(relx=.2, rely=.9, anchor="c", height=25, width=200, bordermode=OUTSIDE,)
    question.grid(row = 0)
    question.place(relx=.5, rely=.1, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_2.place(relx=.5, rely=.6, anchor="c", height=60, width=500, bordermode=OUTSIDE)
    answer.grid(row = 1)
    answer.place(relx=.5, rely=.7, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3.grid(row = 1)
    question_3.place(relx=.5, rely=.2, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_4.grid(row = 1)
    question_4.place(relx=.5, rely=.3, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_5.grid(row = 1)
    question_5.place(relx=.5, rely=.4, anchor="c", height=50, width=500, bordermode=OUTSIDE)

    def game1(que_two):
        if answer.get().lower() == '1':
            correctCount = correctCount + 1
            que_two()
        else:
            incorrectCount = incorrectCount +1
            que_two()


if __name__ == '__main__':
    que_zero()
    root.mainloop()            
python
  • 1 个回答
  • 10 Views
Martin Hope
L0veLy
Asked: 2020-01-30 02:13:20 +0000 UTC

正确和错误答案的计数器

  • 0

我想以界面的形式创建一个测验。一切似乎都完成了,但我不知道如何添加正确答案的计数器,这将显示在下面和最后的消息框中。编码:

from tkinter import *
from tkinter import messagebox

root = Tk()
root.title('Викторина')
root.geometry('600x600')
root["bg"] = "#FFD700"

correctCount = 0
incorrectCount = 0

def que_one():
    question = Label(root, text='Тут будет вопрос', font='20', fg='#000000', bg='#FFE4B5')
    question_2 = Label(root, text='Введи ответ цифрой: ', font='15', fg='#000000')
    answer = Entry(bg='#C0C0C0')
    btn = Button(root, text='Ответить', command=lambda: game1(que_two))
    btn.grid(row = 0)
    btn.place(relx=.5, rely=.8, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3 = Label(root, text='1. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_4 = Label(root, text='2. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_5 = Label(root, text='3. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_6 = Label(root, text='Правильных ответов: 0', font='5', bg='#FFD700')
    question_6.place(relx=.2, rely=.9, anchor="c", height=25, width=200, bordermode=OUTSIDE)
    question.grid(row = 0)
    question.place(relx=.5, rely=.1, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_2.place(relx=.5, rely=.6, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    answer.grid(row = 1)
    answer.place(relx=.5, rely=.7, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3.grid(row = 1)
    question_3.place(relx=.5, rely=.2, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_4.grid(row = 1)
    question_4.place(relx=.5, rely=.3, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_5.grid(row = 1)
    question_5.place(relx=.5, rely=.4, anchor="c", height=50, width=500, bordermode=OUTSIDE)

    def game1(que_two):
        if answer.get().lower() == '1':
            correctCount = correctCount + 1
            que_two()
        else:
            incorrectCount = incorrectCount +1
            que_two()


def que_two():
    question = Label(root, text='Тут будет вопрос', font='20', fg='#000000', bg='#FFE4B5')
    question_2 = Label(root, text='Введи ответ цифрой: ', font='15', fg='#000000')
    answer = Entry(bg='#C0C0C0')
    btn_1 = Button(root, text='Ответить', command=lambda: game2(que_two))
    btn_1.grid(row = 0)
    btn_1.place(relx=.5, rely=.8, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3 = Label(root, text='1. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_4 = Label(root, text='2. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_5 = Label(root, text='3. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question.grid(row = 0)
    question.place(relx=.5, rely=.1, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_2.place(relx=.5, rely=.6, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    answer.grid(row = 1)
    answer.place(relx=.5, rely=.7, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3.grid(row = 1)
    question_3.place(relx=.5, rely=.2, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_4.grid(row = 1)
    question_4.place(relx=.5, rely=.3, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_5.grid(row = 1)
    question_5.place(relx=.5, rely=.4, anchor="c", height=50, width=500, bordermode=OUTSIDE)

    def game2(que_two):
        if answer.get().lower() == '2':
            que_three();
            correctCount = correctCount + 1
        else:
            que_three();
            incorrectCount = incorrectCount +1

def que_three():
    question = Label(root, text='Тут будет вопрос', font='20', fg='#000000', bg='#FFE4B5')
    question_2 = Label(root, text='Введи ответ цифрой: ', font='15', fg='#000000')
    answer = Entry(bg='#C0C0C0')
    btn_1 = Button(root, text='Ответить', command=lambda: game3(que_two))
    btn_1.grid(row = 0)
    btn_1.place(relx=.5, rely=.8, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3 = Label(root, text='1. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_4 = Label(root, text='2. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question_5 = Label(root, text='3. Тут будет ответ', font='15', bg='#DC143C', fg='#FFFFFF')
    question.grid(row = 0)
    question.place(relx=.5, rely=.1, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_2.place(relx=.5, rely=.6, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    answer.grid(row = 1)
    answer.place(relx=.5, rely=.7, anchor="c", height=30, width=500, bordermode=OUTSIDE)
    question_3.grid(row = 1)
    question_3.place(relx=.5, rely=.2, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_4.grid(row = 1)
    question_4.place(relx=.5, rely=.3, anchor="c", height=50, width=500, bordermode=OUTSIDE)
    question_5.grid(row = 1)
    question_5.place(relx=.5, rely=.4, anchor="c", height=50, width=500, bordermode=OUTSIDE)

    def game3(que_two):
        if answer.get().lower() == '2':
            correctCount = correctCount + 1 
            messagebox.showinfo('Правильных ответов: ' + str(correctCount))
        else:
            incorrectCount = incorrectCount +1
            messagebox.showinfo('Правильных ответов: ' + str(correctCount))


que_one()

root.mainloop()
python
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5