DiscordAPIError:未知角色

时间:2020-05-29 17:48:29

标签: bots discord discord.js

我试图在discord.js中发出一条命令,使该机器人找到它可以赋予某人的最高角色并将其赋予该人。

import logging
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.utils.dates import days_ago

default_args = {'start_date': days_ago(1)}


def calculate_date(ds, execution_date, **kwargs):
    return f'{ds} ({execution_date.strftime("%m/%d/%Y")})'


def log_date(date_string):
    logging.info(date_string)


with DAG(
    'a_dag',
    schedule_interval='*/5 * * * *',
    default_args=default_args,
    catchup=False,
) as dag:
    get_date = PythonOperator(
        task_id='get_date',
        python_callable=calculate_date,
        provide_context=True,
    )
    use_date = PythonOperator(
        task_id='use_date',
        python_callable=log_date,
        op_args=['Date: {{ task_instance.xcom_pull(task_ids="get_date") }}'],
    )
get_date >> use_date

然后出现以下错误:

      const myrole = message.guild.me.roles.highest.rawPosition
      const therole = message.guild.roles.cache.find(r => r.rawPosition = myrole-1)
      const person = message.guild.member(client.users.cache.get("the id"))
      person.roles.add(therole.id);

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您当前的代码没有检查r.rawPosition是否等于myrole - 1,而是将r.rawPosition定义为myrole - 1

const myrole = message.guild.me.roles.highest.rawPosition
const therole = message.guild.roles.cache.find(r => r.rawPosition === myrole-1)
const person = message.guild.member(client.users.cache.get("the id"))
person.roles.add(therole.id);