这是主要的.py
from kivy.app import App
class WeatherApp(App):
pass
if __name__ == '__main__':
WeatherApp().run()
Run Code Online (Sandbox Code Playgroud)
天气.kv 是:
AddLocationForm:
<AddLocationForm@BoxLayout>:
orientation: 'vertical'
BoxLayout:
TextInput:
Button:
text: "Search"
Button:
text: "Current Location"
ListView:
item_strings: ["Palo Alto, MX", "Palo Alto, US"]
Run Code Online (Sandbox Code Playgroud)
它似乎无法识别列表视图。我已经看到其他使用带有“from kivy.uix.listview import ListView”的列表视图,但这也不起作用,我不知道为什么。
kivy.factory.FactoryException:未知类
我正在尝试通过 Discord 机器人发送包含链接的消息(例如:有关更多信息,请单击以下链接)。
问题是,每次我发送它时,Discord 都会为该消息生成一个嵌入,这在正常情况下会很好,但我不想要它,因为它看起来非常垃圾邮件。
我尝试用它来停止嵌入embed=None
,但它没有完成它的工作。
msg = await channel.send("Click on this link: https://somewhere.com", embed=None)
Run Code Online (Sandbox Code Playgroud)
Acording to the docs, i should use embed=discord.Embed.Empty
, but it is throwing me an error inside the lib files.
Any ideas? Maybe i could edit the message after sending it and try to remove the embed, but i don't think it will work...
我最近一直在看到具有新的“关于我”功能的机器人!但是,我不知道如何在 Discord.py 机器人上使用它。我已经阅读了 discord.py 文档以查看是否有任何相关信息,但我找不到答案是否可以。
但是我发现了一个具有“关于我”功能的机器人,但它也说它是使用 Discord.py 制作的
有谁知道你将如何启用它?谢谢!
我正在为 discord 服务器制作一个机器人,我想出了以下代码解决方案。这段代码的问题是任何人都可以使用任何命令。我需要将管理命令限制为具有 Admin 角色的用户。我试过这个,但无法弄清楚什么是正确的方法。
#Import
import discord
import os
from discord.ext import commands
#Client
client = commands.Bot(command_prefix='?')
client.remove_command('help')
#Activity
@client.event
async def on_ready():
print('Emog9 is running')
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name="?help"))
#Error
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.reply('Command does not exist. Please use a valid command')
#Cogs
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
Run Code Online (Sandbox Code Playgroud)
Mute.py
:
import discord
from discord.ext import commands
class …
Run Code Online (Sandbox Code Playgroud) 我最近开始玩 discord bots,我有一个疑问,即是否必须async
对不和谐命令使用函数。如果是,那么有人可以告诉我区别吗(根据不和谐的机器人行为)
async-await python-asyncio discord discord.py discord.py-rewrite