如何设置不和谐机器人状态

时间:2021-01-23 15:18:34

标签: node.js discord.js

我希望我的机器人的状态为:我的前缀是 !。 我试过的代码:

client.user.setPresence({
   status: 'online',
   activity: {
      name: 'My prefix is "!" ',
   }
})

错误是: 无法读取属性 setPresence。 所以我尝试了

client.user.setActivity({
   status: 'online',
   activity: {
      name: 'My prefix is "!" ',
   }
})

错误是: 无法读取属性 setActivity。 请帮我。我的不和谐版本:

^12.5.1

2 个答案:

答案 0 :(得分:0)

试试这个:

client.user.setActivity(`My prefix is "!"`, { type: "PLAYING" });

答案 1 :(得分:0)

// Define our Props type to allow the specifying of a Tag for HTML attributes
// Also define children as React does with React.ReactNode
type Props<Tag extends keyof JSX.IntrinsicElements> = {
  tag?: ComponentType | keyof JSX.IntrinsicElements;
  children?: ReactNode;
} & JSX.IntrinsicElements[Tag];

// Define our generic (Tag) again here and give it our default value
// Don't forget to specify the type Props<Tag> at the end of your function's arguments
// Then we can spread all props to the tag/Wrapper
function MyComponent<Tag extends keyof JSX.IntrinsicElements = 'div'>({ tag: Wrapper = 'div', ...props }: Props<Tag>) {
  return <Wrapper {...props} />;
}

// Example usage, noValidate is typed as
// (JSX attribute) React.FormHTMLAttributes<HTMLFormElement>.noValidate?: boolean | undefined
<MyComponent<'form'> tag="form" noValidate>
  {/* My Form Stuff */}
</MyComponent>;

// You don't need to specify 'div' since it is the default
<MyComponent id="page">
  <p>Just a paragraph inside of a regular div</p>
</MyComponent>;

enter image description here