Example #1
0
        public void SetAwayUser(AwaySystem awayInfo)
        {
            var awayUser = new AwaySystem();

            using (var db = new DiscbotContext())
            {
                awayUser = db.AwaySystem.AsEnumerable().Where(a => a.UserName == awayInfo.UserName).FirstOrDefault();
                if (awayUser == null)
                {
                    db.AwaySystem.Add(awayInfo);
                }
                else
                {
                    awayUser.Status   = awayInfo.Status;
                    awayUser.Message  = awayInfo.Message;
                    awayUser.TimeAway = awayInfo.TimeAway;
                }
                db.SaveChanges();
            }
        }
Example #2
0
 public async Task ToggleGiphy()
 {
     try
     {
         StringBuilder sb         = new StringBuilder();
         string        serverName = string.Empty;
         long          serverId   = 0;
         var           guildInfo  = Context.Guild;
         var           embed      = new EmbedBuilder();
         if (guildInfo == null)
         {
             serverName         = Context.User.Username;
             serverId           = (long)Context.User.Id;
             embed.ThumbnailUrl = Context.User.GetAvatarUrl();
         }
         else
         {
             serverName         = Context.Guild.Name;
             serverId           = (long)Context.Guild.Id;
             embed.ThumbnailUrl = Context.Guild.IconUrl;
         }
         using (var db = new DiscbotContext())
         {
             var giphySettings = db.Giphy.FirstOrDefault(g => g.ServerName == serverName);
             if (giphySettings == null)
             {
                 db.Giphy.Add(new Database.Entities.Giphy
                 {
                     GiphyEnabled = true,
                     ServerId     = serverId,
                     ServerName   = serverName
                 });
                 embed.Title = $"Giphy enabled for [**{serverName}**]";
                 sb.AppendLine($":question:__How to use **{_prefix}giphy**__:question:");
                 sb.AppendLine();
                 sb.AppendLine($"**{_prefix}giphy**");
                 sb.AppendLine($"The above command would get a random image");
                 sb.AppendLine();
                 sb.AppendLine($"**{_prefix}giphy Rocket League**");
                 sb.AppendLine($"The above command would get a random image related to Rocket League");
             }
             else if ((bool)giphySettings.GiphyEnabled)
             {
                 giphySettings.GiphyEnabled = false;
                 embed.Title = $"Giphy disabled for [**{serverName}**]";
                 sb.AppendLine();
                 sb.AppendLine($"{Context.User.Username}, I thought this was America!");
             }
             else
             {
                 giphySettings.GiphyEnabled = true;
                 embed.Title = $"Giphy enabled for [**{serverName}**]";
                 sb.AppendLine($":question:__How to use **{_prefix}giphy**__:question:");
                 sb.AppendLine();
                 sb.AppendLine($"**{_prefix}giphy**");
                 sb.AppendLine($"The above command would get a random image");
                 sb.AppendLine();
                 sb.AppendLine($"**{_prefix}giphy Rocket League**");
                 sb.AppendLine($"The above command would get a random image related to Rocket League");
             }
             db.SaveChanges();
         }
         embed.WithColor(new Color(255, 0, 0));
         embed.Description = sb.ToString();
         await _channelServices.Reply(Context, embed);
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Giphy toggle error -> [{ex.Message}]");
         await _channelServices.Reply(Context, $"Error toggling Giphy command...!");
     }
 }