Пример #1
0
        //Set default prefix
        private async Task _client_JoinedGuild(SocketGuild arg)
        {
            if (!_guildRepository.Exists(arg.Id))
            {
                _guildRepository.AddGuild(new Guild()
                {
                    GuildID = arg.Id, Name = arg.Name
                });
            }

            Guild guild = _guildRepository.GetGuildById(arg.Id);

            if (!_prefixRepository.CheckIfGuildHasPrefix(guild.GuildID))
            {
                Prefix pref = new Prefix()
                {
                    PrefixCommand = prefix,
                    Guild         = guild,
                    GuildID       = guild.GuildID
                };

                _prefixRepository.AddPrefix(pref);
            }
            else
            {
                _prefixRepository.ChangePrefix(arg.Id, prefix);
            }

            return;
        }
        public async Task ChangePrefix(string x)
        {
            if (x.Length > 1)
            {
                throw new Exception("You can only have one character as prefix");
            }

            char pref = Convert.ToChar(x);

            Guild guild = _guildRepo.GetGuildById(Context.Guild.Id);

            _prefixRepo.ChangePrefix(guild.GuildID, pref);

            await Context.Channel.SendMessageAsync($"prefix changed to {pref}");
        }