我在 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) 我已经设置了一个 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()
什么是
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
【“使用系统”】是什么意思?为什么没有这些行就无法启动代码?