Пример #1
0
        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));
            }
        }
Пример #2
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestWebhook> > GetWebhooksAsync(RequestOptions options = null)
 => (await SocketTextChannel.GetWebhooksAsync(options))
 .Select(RestWebhookAbstractionExtensions.Abstract)
 .ToArray();
Пример #3
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null)
 => (await SocketTextChannel.GetPinnedMessagesAsync(options))
 .Select(RestMessageAbstractionExtensions.Abstract)
 .ToArray();
Пример #4
0
 /// <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));
 }
Пример #6
0
 /// <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();
Пример #7
0
 /// <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);
Пример #8
0
 /// <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));
Пример #9
0
 /// <inheritdoc />
 public ISocketMessage GetCachedMessage(ulong id)
 => SocketTextChannel.GetCachedMessage(id)
 ?.Abstract();
Пример #10
0
 /// <inheritdoc />
 public IDisposable EnterTypingState(RequestOptions options = null)
 => SocketTextChannel.EnterTypingState(options);
Пример #11
0
 /// <inheritdoc />
 public Task DeleteMessagesAsync(IEnumerable <ulong> messageIds, RequestOptions options = null)
 => SocketTextChannel.DeleteMessagesAsync(messageIds, options);
Пример #12
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
 => SocketTextChannel.DeleteMessageAsync(message, options);
Пример #13
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
 => SocketTextChannel.DeleteMessageAsync(messageId, options);
Пример #14
0
 /// <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));
Пример #15
0
 /// <inheritdoc />
 public Task ModifyAsync(Action <TextChannelProperties> func, RequestOptions options = null)
 => SocketTextChannel.ModifyAsync(func, options);
Пример #16
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(int limit = 100)
 => SocketTextChannel.GetCachedMessages(limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Пример #17
0
 /// <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));
Пример #18
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
 => SocketTextChannel.GetCachedMessages(fromMessage, dir, limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Пример #19
0
 /// <inheritdoc />
 public Task SyncPermissionsAsync(RequestOptions options = null)
 => SocketTextChannel.SyncPermissionsAsync(options);
Пример #20
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IInviteMetadata> > GetInvitesAsync(RequestOptions options = null)
 => (await SocketTextChannel.GetInvitesAsync(options))
 .Select(InviteMetadataAbstractionExtensions.Abstract)
 .ToArray();
Пример #21
0
 /// <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)
 {
 }
Пример #22
0
 /// <inheritdoc />
 public async Task <IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
 => (await SocketTextChannel.GetMessageAsync(id, options))
 ?.Abstract();
Пример #23
0
 /// <inheritdoc />
 public async Task <IRestWebhook> CreateWebhookAsync(string name, Stream avatar = null, RequestOptions options = null)
 => RestWebhookAbstractionExtensions.Abstract(
     await SocketTextChannel.CreateWebhookAsync(name, avatar, options));
Пример #24
0
 /// <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));
 }
Пример #26
0
 internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketTextChannel parent)
     : base(discord, id, guild)
 {
     ParentChannel = parent;
     _members      = new ConcurrentDictionary <ulong, SocketThreadUser>();
 }