public static string Channel(string channelId) => $"channels/{channelId}";
public static string ChannelInvites(string channelId) => $"channels/{channelId}/invites";
public static string ChannelMessages(string channelId) => $"channels/{channelId}/messages";
public static string ChannelMessages(string channelId, int limit) => $"channels/{channelId}/messages?limit={limit}";
public static string ChannelMessages(string channelId, int limit, string relativeId, string relativeDir) => $"channels/{channelId}/messages?limit={limit}&{relativeDir}={relativeId}";
public static string ChannelMessage(string channelId, string msgId) => $"channels/{channelId}/messages/{msgId}";
public static string ChannelMessageAck(string channelId, string msgId) => $"channels/{channelId}/messages/{msgId}/ack";
public static string ChannelPermission(string channelId, string userOrRoleId) => $"channels/{channelId}/permissions/{userOrRoleId}";
public static string ChannelTyping(string channelId) => $"channels/{channelId}/typing";
public static string Channel(long channelId) => $"channels/{channelId}";
public static string ChannelInvites(long channelId) => $"channels/{channelId}/invites";
public static string ChannelMessages(long channelId) => $"channels/{channelId}/messages";
public static string ChannelMessages(long channelId, int limit) => $"channels/{channelId}/messages?limit={limit}";
public static string ChannelMessages(long channelId, int limit, long relativeId, string relativeDir) => $"channels/{channelId}/messages?limit={limit}&{relativeDir}={relativeId}";
public static string ChannelMessage(long channelId, long msgId) => $"channels/{channelId}/messages/{msgId}";
public static string ChannelMessageAck(long channelId, long msgId) => $"channels/{channelId}/messages/{msgId}/ack";
public static string ChannelPermission(long channelId, long userOrRoleId) => $"channels/{channelId}/permissions/{userOrRoleId}";
public static string ChannelTyping(long channelId) => $"channels/{channelId}/typing";
public const string Servers = "guilds";
public static string Server(string serverId) => $"guilds/{serverId}";
public static string ServerBan(string serverId, string userId) => $"guilds/{serverId}/bans/{userId}";
public static string ServerChannels(string serverId) => $"guilds/{serverId}/channels";
public static string ServerInvites(string serverId) => $"guilds/{serverId}/invites";
public static string ServerMember(string serverId, string userId) => $"guilds/{serverId}/members/{userId}";
public static string ServerPrune(string serverId, int days) => $"guilds/{serverId}/prune?days={days}";
public static string ServerRoles(string serverId) => $"guilds/{serverId}/roles";
public static string ServerRole(string serverId, string roleId) => $"guilds/{serverId}/roles/{roleId}";
public static string Server(long serverId) => $"guilds/{serverId}";
public static string ServerBan(long serverId, long userId) => $"guilds/{serverId}/bans/{userId}";
public static string ServerChannels(long serverId) => $"guilds/{serverId}/channels";
public static string ServerInvites(long serverId) => $"guilds/{serverId}/invites";
public static string ServerMember(long serverId, long userId) => $"guilds/{serverId}/members/{userId}";
public static string ServerPrune(long serverId, int days) => $"guilds/{serverId}/prune?days={days}";
public static string ServerRoles(long serverId) => $"guilds/{serverId}/roles";
public static string ServerRole(long serverId, long roleId) => $"guilds/{serverId}/roles/{roleId}";
public const string Invites = "invite";
public static string Invite(string inviteId) => $"invite/{inviteId}";
public static string InviteUrl(string inviteId) => $"https://discord.gg/{inviteId}";
public static string Invite(long inviteId) => $"invite/{inviteId}";
public static string Invite(string inviteIdOrXkcd) => $"invite/{inviteIdOrXkcd}";
public static string InviteUrl(long inviteId) => $"https://discord.gg/{inviteId}";
public static string InviteUrl(string inviteIdOrXkcd) => $"https://discord.gg/{inviteIdOrXkcd}";
public const string Users = "users";
public static string UserAvatar(string userId, string avatarId) => $"users/{userId}/avatars/{avatarId}.jpg";
public static string UserChannels(string userId) => $"users/{userId}/channels";
public static string UserAvatar(long userId, string avatarId) => $"users/{userId}/avatars/{avatarId}.jpg";
public static string UserChannels(long userId) => $"users/{userId}/channels";
public UserChannelEventArgs(User user, Channel channel)
: base(user)
@@ -123,30 +120,29 @@ namespace Discord
private readonly Users _users;
/// <summary> Returns the user with the specified id, along with their server-specific data, or null if none was found. </summary>
public User GetUser(Server server, string userId)
public User GetUser(Server server, long userId)
{
if (server == null) throw new ArgumentNullException(nameof(server));
if (userId == null) throw new ArgumentNullException(nameof(userId));
if (userId <= 0) throw new ArgumentOutOfRangeException(nameof(userId));
CheckReady();
return _users[userId, server.Id];
}
/// <summary> Returns the user with the specified name and discriminator, along withtheir server-specific data, or null if they couldn't be found. </summary>
/// <remarks> Name formats supported: Name and @Name. Search is case-insensitive. </remarks>
public User GetUser(Server server, string username, string discriminator)
public User GetUser(Server server, string username, short discriminator)
{
if (server == null) throw new ArgumentNullException(nameof(server));
if (username == null) throw new ArgumentNullException(nameof(username));
if (discriminator == null) throw new ArgumentNullException(nameof(discriminator));
if (discriminator <= 0) throw new ArgumentOutOfRangeException(nameof(discriminator));
CheckReady();
User user = FindUsers(server, username, discriminator, true).FirstOrDefault();
if (user == null) throw new ArgumentNullException(nameof(user));
if (user.IsPrivate) throw new InvalidOperationException("Unable to edit users in a private channel");
CheckReady();
var serverId = user.Server?.Id;
var serverId = user.Server.Id;
return _api.EditUser(serverId, user.Id,
mute: mute, deaf: deaf,
roles: roles.Select(x => x.Id).Where(x => x != serverId));
roleIds: roles.Select(x => x.Id).Where(x => x != serverId));
}
public Task KickUser(User user)
{
if (user == null) throw new ArgumentNullException(nameof(user));
if (user.IsPrivate) throw new InvalidOperationException("Unable to kick users from a private channel");
return _api.KickUser(user.Server?.Id, user.Id);
return _api.KickUser(user.Server.Id, user.Id);
}
public Task BanUser(User user)
{
if (user == null) throw new ArgumentNullException(nameof(user));
if (user.IsPrivate) throw new InvalidOperationException("Unable to ban users from a private channel");
return _api.BanUser(user.Server?.Id, user.Id);
return _api.BanUser(user.Server.Id, user.Id);
}
public Task UnbanUser(Server server, string userId)
public Task UnbanUser(Server server, long userId)
{
if (server == null) throw new ArgumentNullException(nameof(server));
if (userId == null) throw new ArgumentNullException(nameof(userId));
if (userId <= 0) throw new ArgumentOutOfRangeException(nameof(userId));
return _api.UnbanUser(server.Id, userId);
}
public async Task<int> PruneUsers(string serverId, int days, bool simulate = false)
public async Task<int> PruneUsers(Server server, int days, bool simulate = false)
{
if (serverId == null) throw new ArgumentNullException(nameof(serverId));
if (server == null) throw new ArgumentNullException(nameof(server));
if (days <= 0) throw new ArgumentOutOfRangeException(nameof(days));
CheckReady();
var response = await _api.PruneUsers(serverId, days, simulate);
var response = await _api.PruneUsers(server.Id, days, simulate);
return response.Pruned ?? 0;
}
/// <summary>When Config.UseLargeThreshold is enabled, running this command will request the Discord server to provide you with all offline users for a particular server.</summary>
public void RequestOfflineUsers(string serverId)
public void RequestOfflineUsers(Server server)
{
if (serverId == null) throw new ArgumentNullException(nameof(serverId));
if (server == null) throw new ArgumentNullException(nameof(server));
_dataSocket.SendGetUsers(serverId);
_dataSocket.SendGetUsers(server.Id);
}
public Task EditProfile(string currentPassword = "",
/// <summary> Returns the configuration object used to make this client. Note that this object cannot be edited directly - to change the configuration of this client, use the DiscordClient(DiscordClientConfig config) constructor. </summary>
internal PermissionOverwrite(PermissionTarget targetType, long targetId, uint allow, uint deny)
{
TargetType = targetType;
TargetId = targetId;
@@ -55,20 +55,20 @@ namespace Discord
return _members.Select(x => x.Value);
}
}
private Dictionary<string, User> _members;
private Dictionary<long, User> _members;
private bool _areMembersStale;
/// <summary> Returns a collection of all messages the client has seen posted in this channel. This collection does not guarantee any ordering. </summary>
[JsonIgnore]
public IEnumerable<Message> Messages => _messages.Values;
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.