Exemplo n.º 1
0
        public static async Task SendPM(ulong userId, IDiscordEmbed embed, DatabaseEntityType entityType = DatabaseEntityType.USER, DatabaseSettingId settingId = DatabaseSettingId.PERSONALMESSAGE)
        {
            IUser        m    = Bot.instance.Client.GetUser(userId);
            IDiscordUser user = new RuntimeUser(m);

            if (CanSendNotification(userId, entityType, settingId))
            {
                await user?.SendMessage(embed);
            }
        }
Exemplo n.º 2
0
        public static async Task SendPM(IDiscordUser user, string message, DatabaseEntityType entityType = DatabaseEntityType.USER, DatabaseSettingId settingId = DatabaseSettingId.PERSONALMESSAGE)
        {
            if (CanSendNotification(user.Id, entityType, settingId))
            {
                RuntimeEmbed e = new RuntimeEmbed(new Discord.EmbedBuilder());
                e.Title       = "NOTIFICATION";
                e.Description = message;

                await user.SendMessage(e);
            }
        }
Exemplo n.º 3
0
 public static bool CanSendNotification(ulong id, DatabaseEntityType entityType = DatabaseEntityType.USER, DatabaseSettingId settingId = DatabaseSettingId.PERSONALMESSAGE)
 {
     using (var context = new MikiContext())
     {
         Setting setting = context.Settings.Find(id.ToDbLong(), entityType, settingId);
         if (setting != null)
         {
             return(setting.IsEnabled);
         }
         return(true);
     }
 }
Exemplo n.º 4
0
        public static async Task SendPM(ulong userId, string message, DatabaseEntityType entityType = DatabaseEntityType.USER, DatabaseSettingId settingId = DatabaseSettingId.PERSONALMESSAGE)
        {
            IUser        m    = Bot.instance.Client.GetUser(userId);
            IDiscordUser user = new RuntimeUser(m);

            if (CanSendNotification(userId, entityType, settingId))
            {
                RuntimeEmbed e = new RuntimeEmbed(new Discord.EmbedBuilder());
                e.Title       = "NOTIFICATION";
                e.Description = message;

                await user?.SendMessage(e);

                Log.Message("Sent notification to " + user.Username);
            }
        }