📅  最后修改于: 2023-12-03 14:40:44.757000             🧑  作者: Mango
Using Discord.js, you can set your bot's activity status to anything you want. This can be useful for displaying a status like "Playing Fortnite", "Watching YouTube", or "Listening to Music". In this tutorial, we'll go over how to use the setActivity() method to set your bot's activity.
To follow along with this tutorial, you will need:
To set your bot's activity, you will need to use the setActivity() method provided by the Discord.js library. Here's the basic syntax for using this method:
client.user.setActivity('your activity here');
Replace 'your activity here' with the activity you want your bot to display. You can also customize the type of activity being displayed by passing an object as the second parameter to the setActivity() method. Here are the possible options you can specify:
client.user.setActivity('your activity here', { type: 'PLAYING' });
client.user.setActivity('your activity here', { type: 'STREAMING' });
client.user.setActivity('your activity here', { type: 'LISTENING' });
client.user.setActivity('your activity here', { type: 'WATCHING' });
Replace 'your activity here' with the activity you want your bot to display, and specify the type of activity as one of the four possible options: 'PLAYING', 'STREAMING', 'LISTENING', or 'WATCHING'.
Here's an example of setting your bot's activity to "Playing Fortnite":
client.user.setActivity('Playing Fortnite', { type: 'PLAYING' });
In this tutorial, we went over how to use the setActivity() method provided by the Discord.js library to set your bot's activity status. Remember to replace 'your activity here' with the activity that you want your bot to display, and to specify the type of activity as one of the four possible options: 'PLAYING', 'STREAMING', 'LISTENING', or 'WATCHING'.