Tweaks
This commit is contained in:
@@ -130,6 +130,30 @@ namespace Kehyeedra3
|
||||
var jojoke = WeebClient.DownloadString("https://api.skuldbot.uk/fun/jojoke/?raw");
|
||||
await context.Channel.SendMessageAsync($"{context.User.Mention} is that a fucksnifflerling {jojoke} reference?");
|
||||
}
|
||||
|
||||
if (message.Channel is IGuildChannel chan)
|
||||
{
|
||||
var perms = chan.GetPermissionOverwrite(_bot.CurrentUser);
|
||||
if (perms.HasValue)
|
||||
{
|
||||
if (perms.Value.SendMessages == PermValue.Deny) return;
|
||||
}
|
||||
var botGuild = _bot.GetGuild(chan.GuildId).GetUser(_bot.CurrentUser.Id);
|
||||
bool exit = false;
|
||||
|
||||
botGuild.Roles.OrderByDescending(x => x.Position).ToList().ForEach(x =>
|
||||
{
|
||||
perms = chan.GetPermissionOverwrite(x);
|
||||
|
||||
if (perms.HasValue)
|
||||
{
|
||||
if (perms.Value.SendMessages == PermValue.Deny) { exit = true; return; }
|
||||
}
|
||||
});
|
||||
|
||||
if (exit) return;
|
||||
}
|
||||
|
||||
if (!(message.HasStringPrefix(Configuration.Load().Prefix, ref argPos))) return;
|
||||
{
|
||||
var result = await _cmds.ExecuteAsync(context, argPos, _dmap);
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyVersion>2020.4.0.0</AssemblyVersion>
|
||||
<FileVersion>2020.4.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Addons.Interactive" Version="1.0.1" />
|
||||
<PackageReference Include="Discord.Net" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -7,9 +7,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<PublishDir>bin\Release\netcoreapp2.1\publish\</PublishDir>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>false</SelfContained>
|
||||
<PublishSingleFile>True</PublishSingleFile>
|
||||
<PublishReadyToRun>False</PublishReadyToRun>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -15,27 +15,31 @@ namespace Kehyeedra3.Services
|
||||
}
|
||||
public async Task Tick()
|
||||
{
|
||||
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
|
||||
while (true)
|
||||
{
|
||||
List<Reminder> toRemove = new List<Reminder>();
|
||||
while (true)
|
||||
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
|
||||
{
|
||||
var reminders = Database.Reminders.ToList();
|
||||
if(Database.Reminders.Any() && Bot._bot != null && Bot._bot.ConnectionState == Discord.ConnectionState.Connected)
|
||||
{
|
||||
foreach(var x in Database.Reminders)
|
||||
bool hasChanged = false;
|
||||
foreach (var x in reminders)
|
||||
{
|
||||
if (x.Send <= DateTime.UtcNow.ToYeedraStamp())
|
||||
{
|
||||
await SendReminderAsync(x).ConfigureAwait(false);
|
||||
toRemove.Add(x);
|
||||
Database.Reminders.Remove(x);
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
Database.Reminders.RemoveRange(toRemove);
|
||||
await Database.SaveChangesAsync().ConfigureAwait(false);
|
||||
toRemove.Clear();
|
||||
|
||||
if (hasChanged)
|
||||
{
|
||||
await Database.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
await Task.Delay(250);
|
||||
}
|
||||
await Task.Delay(250);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user