public async Task Announce(params string[] str) { Console.WriteLine(string.Format("{0} Executing Command: {1} by {2}", DateTime.Now.ToString("hh:mm:ss"), "announce", Context.User.Username)); Discord.WebSocket.SocketTextChannel channel = null; bool isFirstArgChannel = false; if (str.Length == 0) { await ReplyAsync("The format for this command is !announce <channel> <message>"); } else { //Argument of GetChannelAsync is obtained through the ChannelID on discord, through enabling developer mode switch (string.Format(str[0])) { case "general": channel = await Context.Guild.GetChannelAsync(117894147792175108) as SocketTextChannel; isFirstArgChannel = true; break; case "thelab": channel = await Context.Guild.GetChannelAsync(304502202490290176) as SocketTextChannel; isFirstArgChannel = true; break; default: await Context.Channel.SendMessageAsync("Please include a proper text channel name."); break; } } if (isFirstArgChannel) { await channel.SendMessageAsync(ConstructMessage(str)); } }
/// <inheritdoc /> public async Task <IReadOnlyCollection <IRestWebhook> > GetWebhooksAsync(RequestOptions options = null) => (await SocketTextChannel.GetWebhooksAsync(options)) .Select(RestWebhookAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null) => (await SocketTextChannel.GetPinnedMessagesAsync(options)) .Select(RestMessageAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public async Task <IUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null) => (await SocketTextChannel.ModifyMessageAsync(messageId, func, options)) ?.Abstract();
public static bool HasPermission(this SocketTextChannel context, ChannelPermission permission) { return(context.Guild.CurrentUser.GetPermissions(context).ToList().Contains(permission)); }
/// <inheritdoc /> public async Task <IInviteMetadata> CreateInviteAsync(int?maxAge = 86400, int?maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => (await SocketTextChannel.CreateInviteAsync(maxAge, maxUses, isTemporary, isUnique, options)) .Abstract();
/// <summary> /// Converts an existing <see cref="SocketTextChannel"/> to an abstracted <see cref="ISocketTextChannel"/> value. /// </summary> /// <param name="socketTextChannel">The existing <see cref="SocketTextChannel"/> to be abstracted.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="socketTextChannel"/>.</exception> /// <returns>An <see cref="ISocketTextChannel"/> that abstracts <paramref name="socketTextChannel"/>.</returns> public static ISocketTextChannel Abstract(this SocketTextChannel socketTextChannel) => new SocketTextChannelAbstraction(socketTextChannel);
/// <inheritdoc /> public async Task <IRestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null) => RestUserMessageAbstractionExtensions.Abstract( await SocketTextChannel.SendMessageAsync(text, isTTS, embed, options));
/// <inheritdoc /> public ISocketMessage GetCachedMessage(ulong id) => SocketTextChannel.GetCachedMessage(id) ?.Abstract();
/// <inheritdoc /> public IDisposable EnterTypingState(RequestOptions options = null) => SocketTextChannel.EnterTypingState(options);
/// <inheritdoc /> public Task DeleteMessagesAsync(IEnumerable <ulong> messageIds, RequestOptions options = null) => SocketTextChannel.DeleteMessagesAsync(messageIds, options);
/// <inheritdoc /> public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) => SocketTextChannel.DeleteMessageAsync(message, options);
/// <inheritdoc /> public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) => SocketTextChannel.DeleteMessageAsync(messageId, options);
/// <inheritdoc /> public async Task <IRestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null) => RestUserMessageAbstractionExtensions.Abstract( await SocketTextChannel.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference));
/// <inheritdoc /> public Task ModifyAsync(Action <TextChannelProperties> func, RequestOptions options = null) => SocketTextChannel.ModifyAsync(func, options);
/// <inheritdoc /> public IReadOnlyCollection <ISocketMessage> GetCachedMessages(int limit = 100) => SocketTextChannel.GetCachedMessages(limit) .Select(SocketMessageAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public async Task <IRestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false) => RestUserMessageAbstractionExtensions.Abstract( await SocketTextChannel.SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler));
/// <inheritdoc /> public IReadOnlyCollection <ISocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100) => SocketTextChannel.GetCachedMessages(fromMessage, dir, limit) .Select(SocketMessageAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public Task SyncPermissionsAsync(RequestOptions options = null) => SocketTextChannel.SyncPermissionsAsync(options);
/// <inheritdoc /> public async Task <IReadOnlyCollection <IInviteMetadata> > GetInvitesAsync(RequestOptions options = null) => (await SocketTextChannel.GetInvitesAsync(options)) .Select(InviteMetadataAbstractionExtensions.Abstract) .ToArray();
/// <summary> /// Constructs a new <see cref="SocketTextChannelAbstraction"/> around an existing <see cref="WebSocket.SocketTextChannel"/>. /// </summary> /// <param name="socketTextChannel">The value to use for <see cref="WebSocket.SocketTextChannel"/>.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="socketTextChannel"/>.</exception> public SocketTextChannelAbstraction(SocketTextChannel socketTextChannel) : base(socketTextChannel) { }
/// <inheritdoc /> public async Task <IMessage> GetMessageAsync(ulong id, RequestOptions options = null) => (await SocketTextChannel.GetMessageAsync(id, options)) ?.Abstract();
/// <inheritdoc /> public async Task <IRestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null) => RestWebhookAbstractionExtensions.Abstract( await SocketTextChannel.CreateWebhookAsync(name, avatar, options));
/// <inheritdoc /> public IAsyncEnumerable <IReadOnlyCollection <IMessage> > GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null) => SocketTextChannel.GetMessagesAsync(fromMessage, dir, limit, options) .Select(x => x .Select(MessageAbstractionExtensions.Abstract) .ToArray());
public static bool HasPermission(this SocketTextChannel channel, SocketGuildUser user, ChannelPermission permission) { return(user.GetPermissions(channel).ToList().Contains(permission)); }
internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketTextChannel parent) : base(discord, id, guild) { ParentChannel = parent; _members = new ConcurrentDictionary <ulong, SocketThreadUser>(); }