Exemple #1
0
        public async Task SendLogAsync(IGuild guild, string title, string description)
        {
            var channelId = await _servers.GetLogsAsync(guild.Id);

            if (channelId == 0)
            {
                return;
            }

            var fetchedChannel = await guild.GetTextChannelAsync(channelId);

            if (fetchedChannel == null)
            {
                await _servers.ClearLogsAsync(guild.Id);

                return;
            }

            await fetchedChannel.SendLogAsync(title, description);
        }
Exemple #2
0
        public async Task Logs(string value = null)
        {
            if (value == null)
            {
                var fetchedChannelId = await _servers.GetLogsAsync(Context.Guild.Id);

                if (fetchedChannelId == 0)
                {
                    await Context.Channel.SendErrorAsync("Error", "There has not been set a logs channel yet!");

                    return;
                }

                var fetchedChannel = Context.Guild.GetTextChannel(fetchedChannelId);
                if (fetchedChannel == null)
                {
                    await Context.Channel.SendErrorAsync("Error", "There has not been set a logs channel yet!");

                    await _servers.ClearLogsAsync(Context.Guild.Id);

                    return;
                }

                await ReplyAsync($"The channel used for the logs is set to {fetchedChannel.Mention}.");

                return;
            }

            if (value != "clear")
            {
                if (!MentionUtils.TryParseChannel(value, out var parsedId))
                {
                    await Context.Channel.SendErrorAsync("Error", "Please pass in a valid channel!");

                    return;
                }

                var parsedChannel = Context.Guild.GetTextChannel(parsedId);
                if (parsedChannel == null)
                {
                    await ReplyAsync("Please pass in a valid channel!");

                    return;
                }

                await _servers.ModifyLogsAsync(Context.Guild.Id, parsedId);

                await Context.Channel.SendSuccessAsync("Success",
                                                       $"Successfully modified the logs channel to {parsedChannel.Mention}.");

                return;
            }

            if (value == "clear")
            {
                await _servers.ClearLogsAsync(Context.Guild.Id);

                await Context.Channel.SendSuccessAsync("Success", "Successfully cleared the logs channel.");

                return;
            }

            await Context.Channel.SendErrorAsync("Error", "You did not use this command properly.");
        }