Esempio n. 1
0
        private Task _client_UserJoined(SocketGuildUser arg)
        {
            using (BotDbContext dbcontext = new BotDbContext())
            {
                DiscordGuildModel GuildModel = dbcontext.GetGuild(arg.Guild.Id);

                if (GuildModel == null)
                {
                    GuildModel = dbcontext.GreateGuild(new DiscordGuildModel()
                    {
                        GuildId = arg.Guild.Id
                    });
                }

                if (GuildModel.WellcomeChannelId != default)
                {
                    var channel = arg.Guild.GetChannel(GuildModel.WellcomeChannelId) as IMessageChannel;
                    if (channel != null)
                    {
                        channel.SendMessageAsync("Hi " + arg.Mention + ". Happy to see you.");
                    }
                }
            }

            return(Task.CompletedTask);
        }
Esempio n. 2
0
        public async Task Setwellcome()
        {
            using (BotDbContext dbcontext = new BotDbContext())
            {
                DiscordGuildModel GuildModel = dbcontext.GetGuild(Context.Guild.Id);

                if (GuildModel == null)
                {
                    GuildModel = dbcontext.GreateGuild(new DiscordGuildModel()
                    {
                        GuildId = Context.Guild.Id
                    });
                }

                if (GuildModel.WellcomeChannelId == Context.Channel.Id)
                {
                    GuildModel.WellcomeChannelId = default;
                    await ReplyAsync("Wellcome channel removed");
                }
                else
                {
                    GuildModel.WellcomeChannelId = Context.Channel.Id;
                    await ReplyAsync("Wellcome channel set");
                }

                dbcontext.Update(GuildModel);
                dbcontext.SaveChanges();
            }
        }
Esempio n. 3
0
        public DiscordGuildModel GreateGuild(DiscordGuildModel discordGuild = null)
        {
            if (discordGuild == null)
            {
                discordGuild = new DiscordGuildModel();
            }

            Add(discordGuild);
            SaveChanges();
            return(discordGuild);
        }
Esempio n. 4
0
        private Task _client_JoinedGuild(SocketGuild arg)
        {
            using (BotDbContext dbcontext = new BotDbContext())
            {
                DiscordGuildModel GuildModel = dbcontext.GetGuild(arg.Id);

                if (GuildModel == null)
                {
                    dbcontext.GreateGuild(new DiscordGuildModel()
                    {
                        GuildId = arg.Id
                    });
                }
            }

            return(Task.CompletedTask);
        }