Beispiel #1
0
 public async Task AnnounceJoinedUser(SocketGuildUser user)
 {
     SilverBotData.Serverthing thing = SilverBotLiteData.Serverthing.Getbyid(user.Guild.Id);
     if (thing != null)
     {
         ulong id = thing.ChannelId;
         if (_client.GetChannel(id) is not SocketTextChannel channel)
         {
             Console.WriteLine("deleted " + thing.ChannelId + " as it returned null" + SilverBotLiteData.Serverthing.Removebyid(id, user.Guild.Id));
             return;
         }
         EmbedBuilder b = new EmbedBuilder();
         b.WithTitle("Welcome " + user.Username + " to the " + user.Guild.Name + " discord server");
         b.WithDescription("You are the " + user.Guild.MemberCount + "th member.");
         b.WithFooter("Requested by CONSOLE", "https://cdn.discordapp.com/attachments/728360861483401240/728362412373180566/console.png");
         b.WithThumbnailUrl(user.GetAvatarUrl());
         if (user.GetAvatarUrl() == null)
         {
             b.WithThumbnailUrl(user.GetDefaultAvatarUrl());
         }
         try
         {
             await channel.SendMessageAsync("", false, b.Build());
         }
         catch (Exception err)
         {
             SentrySdk.CaptureException(err);
             throw;
         }
     }
 }
        public static void Insert(SilverBotData.Serverthing thing)
        {
            using LiteDatabase db = new LiteDatabase(@"Filename=serverdata.db; Connection=shared");
            ILiteCollection <SilverBotData.Serverthing> col = db.GetCollection <SilverBotData.Serverthing>();

            col.Insert(thing);
        }