示例#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>();
 }