public async Task SetAnnouncementChannel(ITextChannel channel)
        {
            var guildAcc = _globalGuildAccounts.GetById(Context.Guild.Id);

            guildAcc.Modify(g => g.SetAnnouncementChannelId(channel.Id), _globalGuildAccounts);
            await ReplyAsync("The Announcement-Channel has been set to " + channel.Mention);
        }
Ejemplo n.º 2
0
        public async Task ShowTag(string tagName)
        {
            if (string.IsNullOrWhiteSpace(tagName))
            {
                await ReplyAsync("You need to use this with some more input...\n" +
                                 "Try the `help tag` command to get more information on how to use this command.");

                return;
            }
            var guildAcc = _globalGuildAccounts.GetById(Context.Guild.Id);
            var response = TagFunctions.GetTag(tagName, guildAcc);

            await ReplyAsync(response);
        }
Ejemplo n.º 3
0
        public async Task AddPrefix([Remainder] string prefix)
        {
            var guildAcc = _globalGuildAccounts.GetById(Context.Guild.Id);
            var response = $"Failed to add the Prefix... Was `{prefix}` already a prefix?";

            if (!guildAcc.Prefixes.Contains(prefix))
            {
                var prefixes = guildAcc.Prefixes.ToList();
                guildAcc.Modify(g => g.SetPrefixes(prefixes.Append(prefix).ToList()), _globalGuildAccounts);
                response = $"Successfully added `{prefix}` as prefix!";
            }

            await ReplyAsync(response);
        }
        public async Task UserJoined(SocketGuildUser user)
        {
            var dmChannel = await user.GetOrCreateDMChannelAsync();

            var possibleMessages = _globalGuildAccounts.GetById(user.Guild.Id).WelcomeMessages;
            var messageString    = possibleMessages[Global.Rng.Next(possibleMessages.Count)];

            messageString = messageString.ReplacePlacehoderStrings(user);
            if (string.IsNullOrEmpty(messageString))
            {
                return;
            }
            await dmChannel.SendMessageAsync(messageString);
        }
        public async Task AddWelcomeMessage([Remainder] string message)
        {
            var guildAcc = _globalGuildAccounts.GetById(Context.Guild.Id);
            var response = $"Failed to add this Welcome Message...";

            if (!guildAcc.WelcomeMessages.Contains(message))
            {
                var messages = guildAcc.WelcomeMessages.ToList();
                messages.Add(message);
                guildAcc.Modify(g => g.SetWelcomeMessages(messages), _globalGuildAccounts);
                response = $"Successfully added ```\n{message}\n``` as Welcome Message!";
            }

            await ReplyAsync(response);
        }
Ejemplo n.º 6
0
        public static Task Init(GlobalGuildAccounts globalGuildAccounts)
        {
            data = new AllGuildsData();

            foreach (SocketGuild guild in Global.Client.Guilds)
            {
                GuildData savedData = globalGuildAccounts.GetById(guild.Id).BotData;
                if (savedData == null)
                {
                    AddGuild(guild.Id);
                }
                else
                {
                    data.guilds.Add(savedData);
                }
                StoreData(guild.Id, globalGuildAccounts);
            }

            return(Task.CompletedTask);
        }
        private bool CheckPrefix(ref int argPos, SocketCommandContext context)
        {
            if (context.Guild is null)
            {
                return(false);
            }
            var prefixes  = _globalGuildAccounts.GetById(context.Guild.Id).Prefixes;
            var tmpArgPos = 0;
            var success   = prefixes.Any(pre =>
            {
                if (!context.Message.Content.StartsWith(pre))
                {
                    return(false);
                }
                tmpArgPos = pre.Length;
                return(true);
            });

            argPos = tmpArgPos;
            return(success);
        }
Ejemplo n.º 8
0
        private static void StoreData(ulong id, GlobalGuildAccounts globalGuildAccounts)
        {
            var guildAccount = globalGuildAccounts.GetById(id);

            guildAccount.Modify(g => g.SetBotData(data.GetGuild(id)), globalGuildAccounts);
        }