Exemplo n.º 1
0
        // Remove a server from our Guild Channel data if someone removes us
        private Task OnGuildLeft(SocketGuild guild)
        {
            var data         = DataStorage.LoadGuildChannelData(Config.GuildChannelsFile);
            var modifiedData = data.ToList();

            if (modifiedData.Any(x => x.GuildID == guild.Id))
            {
                modifiedData.Remove(modifiedData.First(x => x.GuildID == guild.Id));

                DataStorage.SaveGuildChannelData(modifiedData, Config.GuildChannelsFile);
                Console.WriteLine($"Left {guild.Name}. They were subsribed, so I removed them.");
            }
            else
            {
                Console.WriteLine($"Left {guild.Name}. They were not subscribed.");
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public async Task Unsubscribe()
        {
            try
            {
                var user = (SocketGuildUser)Context.User;
                if (user.GuildPermissions.Administrator)
                {
                    var data         = DataStorage.LoadGuildChannelData(Config.GuildChannelsFile);
                    var modifiedData = data.ToList();

                    if (modifiedData.Any(x => x.GuildID == Context.Guild.Id))
                    {
                        modifiedData.Remove(modifiedData.First(x => x.GuildID == Context.Guild.Id));

                        DataStorage.SaveGuildChannelData(modifiedData, Config.GuildChannelsFile);
                        await Context.Channel.PrintSuccess(
                            $"This server is no longer subscribed to ARK notifications. You can subscribe again by doing `!ark subscribe`");
                    }
                    else
                    {
                        await Context.Channel.PrintError("This server is not subscribed to ARK notifications. You can subscribe by doing `!ark subscribe`");
                    }
                }
                else
                {
                    await Context.Channel.PrintError("Sorry, you must be an administrator to unsubscribe to ARK.");
                }
            }
            catch (HttpException e)
            {
                if (e.HttpCode == HttpStatusCode.Forbidden)
                {
                    await Context.User.PrintNoPermissionsMessage();
                }
            }
        }
Exemplo n.º 3
0
 public static void SaveGuildChannelData() => DataStorage.SaveGuildChannelData(guildChannelData, Config.GuildChannelsFile);