33 lines
968 B
C#
33 lines
968 B
C#
namespace FluxPose.DiscordBot.Experimenting;
|
|
|
|
public class Actions<TContext>(Users.Actions<TContext> usersActions, GatewayClient client, TContext context) : ActionsBase<TContext>(context) where TContext : IInteractionContext
|
|
{
|
|
public async Task<GuildUser?> GetRandomUserFromGuild()
|
|
{
|
|
var users = await usersActions.GetAllUsersFromGuild();
|
|
|
|
var index = new Random().Next(users.Count);
|
|
return users[index];
|
|
}
|
|
|
|
public async Task RemoveRoleFromAllUsers(ulong roleId)
|
|
{
|
|
var users = await usersActions.GetAllUsersFromGuild();
|
|
|
|
foreach (var user in users)
|
|
{
|
|
if (user.RoleIds.Contains(roleId))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
await client.Rest.RemoveGuildUserRoleAsync(GuildId, user.Id, roleId);
|
|
}
|
|
}
|
|
|
|
public async Task<IReadOnlyList<GuildEmoji>> GetAllGuildEmoji()
|
|
{
|
|
return await client.Rest.GetGuildEmojisAsync(GuildId);
|
|
}
|
|
}
|