async Task InitializeDiscord()
        {
            client = new DiscordRestClient();
            await client.LoginAsync(TokenType.Bot, token);

            channel = await client.GetChannelAsync(GeneralChannelId) as RestTextChannel;
        }
        async Task InitializeDiscord(string token)
        {
            client = new DiscordRestClient();

            await client.LoginAsync(TokenType.Bot, "NDU5NzM3ODk4NjUzMzE5MTY4.XrA89w.H6nM6U4zhpde3gJOu471KEErMJQ");

            channel = await client.GetChannelAsync(GeneralChannelId) as RestTextChannel;
        }
Example #3
0
        private async Task SendEmbed(Embed embed)
        {
            await discord.LoginAsync(TokenType.Bot, _config["token"]);

            var selectedChannel = boxChannels.SelectedItem as RestGuildChannel;
            var channel         = await discord.GetChannelAsync(selectedChannel.Id);

            await(channel as IRestMessageChannel).SendMessageAsync(null, false, embed);
        }
        private async Task <DiscordChannel> FindLogChannel(ulong guild, ulong channel)
        {
            try
            {
                return(await _rest.GetChannelAsync(channel));
            }
            catch (NotFoundException)
            {
                // Channel doesn't exist, let's remove it from the database too
                _logger.Warning("Attempted to fetch missing log channel {LogChannel}, removing from database", channel);
                await using var conn = await _db.Obtain();

                await conn.ExecuteAsync("update servers set log_channel = null where server = @Guild",
                                        new { Guild = guild });
            }

            return(null);
        }
        public async Task <IMessageChannel> GetChannelAsync(decimal id)
        {
            var channelId = Convert.ToUInt64(id);

            return(await _DiscordClient.GetChannelAsync(channelId) as IMessageChannel);
        }
Example #6
0
 public static Task <DiscordChannel> GetChannel(this DiscordRestClient client, ulong id) =>
 WrapDiscordCall(client.GetChannelAsync(id));
Example #7
0
        private async Task <IMessageChannel> GetChannel(string id)
        {
            IMessageChannel channel = await _restClient.GetChannelAsync(Convert.ToUInt64(id.Split(":")[1])) as IMessageChannel;

            return(channel);
        }