小编Mac*_*Fan的帖子

不和谐.py | 为某人添加角色

我在 discord.py 中创建“添加角色”命令时遇到问题。我不知道出了什么问题;它只是不起作用。

@client.command()
@commands.has_role("Admin")
async def addrole(ctx):
    user = ctx.message.author
    role = discord.utils.get(user.server.roles, name="Test")
    await client.add_roles(user, role)
Run Code Online (Sandbox Code Playgroud)

python discord.py

5
推荐指数
3
解决办法
6万
查看次数

如何在 discord.py cogs 中创建别名?

我已经设置了一个 discord.py cog,可以使用了。有一个问题,如何为命令设置别名?我会在下面给你我的代码,看看我还需要做什么:

# Imports
from discord.ext import commands
import bot  # My own custom module


# Client commands
class Member(commands.Cog):
    def __init__(self, client):
        self.client = client

    # Events
    @commands.Cog.listener()
    async def on_ready(self):
        print(bot.online)

    # Commands
    @commands.command()
    async def ping(self, ctx):
        pass


# Setup function
def setup(client):
    client.add_cog(Member(client))
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我应该如何为下的ping命令设置别名@commands.command()

python python-3.x discord.py-rewrite

3
推荐指数
1
解决办法
8175
查看次数

C# 中“使用系统”是什么意思?

什么是

using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

【“使用系统”】是什么意思?为什么没有这些行就无法启动代码?

c# using

-4
推荐指数
1
解决办法
4万
查看次数

标签 统计

python ×2

c# ×1

discord.py ×1

discord.py-rewrite ×1

python-3.x ×1

using ×1