Вы можете использовать System.Threading.Timer
для достижения этой цели.
//add this namespace
using System.Threading;
//create your Timer
private Timer _timer;
//create your list of statuses and an indexer to keep track
private readonly List<string> _statusList = new List<string>() { "first status", "second status", "another status", "last?" };
private int _statusIndex = 0;
Вы можете использовать готовое событие, чтобы начать. Просто подпишитесь на событие Ready на DiscordSocketClient
private Task Ready()
{
_timer = new Timer(async _ =>
{//any code in here will run periodically
await _client.SetGameAsync(_statusList.ElementAtOrDefault(_statusIndex), type: ActivityType.Playing); //set activity to current index position
_statusIndex = _statusIndex + 1 == _statusList.Count ? 0 : _statusIndex + 1; //increment index position, restart if end of list
},
null,
TimeSpan.FromSeconds(1), //time to wait before executing the timer for the first time (set first status)
TimeSpan.FromSeconds(10)); //time to wait before executing the timer again (set new status - repeats indifinitely every 10 seconds)
return Task.CompletedTask;
}