如何获得消息中提到的用户的id?我正在尝试执行一个命令,其中需要命令中提到的用户id。到目前为止,我的代码如下:
@commands.command()
async def fight(self, ctx):
# Send command message
await ctx.send('You need to tag someone: .fight @user')
if user.mention in ctx.content:
if user.mention == self.client.user:
await
我正在尝试做一个机器人,自动使2个团队和移动每个团队到他们自己的语音通道。我列出了两个代表团队的列表。我尝试使用for循环将所有用户转移到他们的语音呼叫。然而,当我运行它时,我得到了这个错误消息:AttributeError: 'int' object has no attribute 'move_to'。我还尝试了打印userID,根据我所看到的资源,我得到了我应该得到的userID。 下面是我正在讨论的代码的一部分: if msg == "!start" and matchmaking:
members = hub.members
码
global Vc
global Tune
try:
Vc = await stage.connect()
member = guild.get_member(config["bot_id"])
await member.edit(suppress=False)
except CommandInvokeError:
pass
while True:
while Vc.is_playing():
await asyncio.sleep(1)
我正在尝试为我正在尝试创建的函数创建一个私有vc。它使vc具有我想要的权限,但在它创建之后,它给出了一个错误,并且我不能将任何代码放在它后面。代码如下: guild = ctx.author.guild
players_role = await guild.create_role(name=f"Players {game_id}")
for i in all_players:
print(all_players)
print(i)
i = guild.get_member(int(i[1]))
await i.add_roles(players
@commands.Cog.listener()
async def on_voice_state_update(self, channel, before, after, member):
channel = self.bot.get_channel([CHANNEL-ID])
member = VoiceChannel.members
if before.channel is None and after.channel is not None:
await channel.send(f'
我在我的一个小服务器上安装了一个discord.py机器人。我已经设置了一个音乐命令,它从YouTube下载一首歌曲并输出到VC中。目前,命令下载整首歌曲,将其转换,然后将其输出到VC中,但是这个过程非常慢。我将如何直接将音频传输到VC中?我愿意使用youtube_dl来代替pytube3。我不太关心更小的代码优化,因为对于我和几个朋友来说,这只是一个小的机器人。
谢谢您的意见!
@bot.command()
async def play(ctx, *song):
if ctx.author.voice is None or ctx.author.voice.channel is No
我正在使用Replit制造一个不和谐的机器人。
if msgtxt in listBadWords:
await message.channel.send(mention + ", your message has been reported to Arunga")
await message.channel.send("Please do not repeat the same mistake again. Do not say bad words!")
user = client.get_user(int(userid))
因此,我尝试创建一个on_user_update事件并发送需要获取设置为公会日志通道的channel_id的消息,我按guild_id对其进行排序,但on_user_update没有公会属性。那么我该如何实现我的目标呢? 代码如下: @bot.event
async def on_user_update(before, after):
async with aiosqlite.connect('database.sqlite') as db:
async with db.execute("SELECT channel_id FROM logg
if "USER ID" in user_message.lower(
) and username != "Ticket Tool" and "Jack PA " not in username:
await message.delete()
await message.channel.send(
f'{username} Please do not ping the owners they are very busy. \nIf you need them open a ticket in ︱o
我决定试着让我的不和谐机器人播放音乐,但我已经卡住了。主要是因为我找不到任何帮助当前版本的资源,所以我一直在即兴使用文档中的所有内容。但是,我不知道如何检查机器人是否连接到语音通道。 我试过if not Client.is_connected():,但是不起作用。如果有任何更新的资源来帮助我了解discord.py的语音特性的基础知识,请给我一个链接:)这是我到目前为止的代码: # ----- ATTEMPT AT VOICE COMMANDS ------
#discord.opus.load_opus() - what goes in bracket???
@client.comman
我是说头衔说明了一切。 我如何从这个“成员”命令中获取id?当特定的人加入vc时,我正在尝试向通道发送消息。但我不知道如何获得加入vc的人的id。我阅读了一些关于这方面的文档,所有这些文档都像message.author.id或smth。我是个新手。考虑解释一下:) @client.event
async def on_voice_state_update(member, before, after):
if not before.channel and after.channel:
channel = client.get_channel("channel id here
我为此编写了代码,但我希望将更多的语音-文本通道连接到语音通道 @bot.event
async def voice1_role(member, before, after):
if not before.channel and after.channel:
role = discord.utils.get(member.guild.roles, name="voice1")
await member.add_roles(role)
elif before.channel and not after.channel:
//function fires after special command every 100 milliseconds
function searchSpeaking(roleSpeak){
//checks every channel; giving you member-channel and its chanId-id
bot.channels.forEach((channel, chanId) => {
//filters out text channels
if (channel.type == 'voice'
所以,大家好,这里的问题是,我希望我的机器人DM我加入一个服务器,目前,我正在使用这个代码,它不工作,但它也没有给我任何错误。
@client.event
async def on_guild_join(guild):
print(f"bot has joined {client.guild.name} and we have {len(client.guilds)} servers")
user = discord.User(my_user_id)
await user.send(f"bot has joined {client.guild.name}
我正试着制造我的第一个机器人来解决不和。我想要实现的是获取服务器中所有角色的颜色。我怎么能这么做?我搜索,但我只发现如何设置一个角色的颜色,而不是如何获得当前的颜色。提前感谢您的帮助。
@client.command()
async def roles_colors(ctx):
for role in ctx.guild.roles:
await ctx.send(role.name)
await ctx.send(discord.role.color)