【发布时间】:2020-02-22 23:47:07
【问题描述】:
我有这个代码:
import discord
from discord.ext import commands, tasks
import random
from itertools import cycle
from discord.utils import get
import os
bot = commands.Bot(command_prefix='-')
TOKEN = ''
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
@commands.has_role('Admin')
async def test(ctx):
await ctx.send(":smiley: :wave: Hello, there! :heart: ")
bot.run(TOKEN)
如何设置拒绝消息? 我的意思是如果有人使用该命令但他没有管理员角色,机器人会说类似 “你不是管理员伙伴!”
我试过了,但没用
@bot.command()
@commands.has_role('Admin')
async def test(ctx):
await ctx.send(":smiley: :wave: Hello, there! :heart: ")
else:
await ctx.send("You can't use this!")
【问题讨论】:
标签: python python-3.x discord roles discord.py