Browse Source

Updated to the latest Discord.NET version and corrected a few things.

master
PHENOMICAL 5 years ago
parent
commit
45b4dda59f
  1. 14
      Omegle-Discord-Bot/Modules/OmegleModule/Emojis.cs
  2. 8
      Omegle-Discord-Bot/Modules/OmegleModule/Preconditions.cs
  3. 37
      Omegle-Discord-Bot/Modules/OmegleModule/Service.cs
  4. 4
      Omegle-Discord-Bot/Omegle-Discord-Bot.csproj

14
Omegle-Discord-Bot/Modules/OmegleModule/Emojis.cs

@ -0,0 +1,14 @@
using Discord;
namespace Omegle_Discord_Bot.Modules.OmegleModule
{
static class Emojis
{
//public static Emoji FOO = new Emoji ("\U00000000");
public static Emoji ARROW_COUNTERCLOCKWISE = new Emoji ("\U0001F504");
public static Emoji STOP_BUTTON = new Emoji ("\U000023F9");
public static Emoji X = new Emoji ("\U0000274C");
public static Emoji FAST_FORWARD = new Emoji ("\U000023E9");
public static Emoji REGIONAL_INDICATOR_X = new Emoji ("\U0001F1FD");
}
}

8
Omegle-Discord-Bot/Modules/OmegleModule/Preconditions.cs

@ -13,7 +13,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
{
public class PermissionReader : PreconditionAttribute
{
public async override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
{
await context.Channel.SendMessageAsync("CheckPermissions(...) not implemented!");
return PreconditionResult.FromError("Not implemented!");
@ -70,7 +70,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
this.userPrivilege = userPrivilege;
}
public async override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
{
MainDatabase database = services.GetService<MainDatabase>();
if (isOverridePermissionHolder(context)) return PreconditionResult.FromSuccess();
@ -93,7 +93,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
public class RequireCreateSessionPermission : PermissionReader
{
public async override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
{
if (context.Channel is IDMChannel)
{
@ -117,7 +117,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
public class RequireBotOwner : PreconditionAttribute
{
public async override Task<PreconditionResult> CheckPermissions(ICommandContext context, CommandInfo command, IServiceProvider services)
public override async Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
{
Configuration config = services.GetService<Configuration>();
//Check if User Is Botowner

37
Omegle-Discord-Bot/Modules/OmegleModule/Service.cs

@ -210,6 +210,13 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
{
//Connect
await session.startSession(lang, unmoderated, topics);
EmbedBuilder embeddedBuilder = new EmbedBuilder();
embeddedBuilder.WithTitle("Started an Omegle Session!");
embeddedBuilder.AddField("Channel", "<#" + channel.Id + ">", true);
embeddedBuilder.AddField("User", "<@" + context.User.Id + ">", true);
embeddedBuilder.AddField("Date", DateTime.Now);
await context.Channel.SendMessageAsync("", false, embeddedBuilder.Build());
client.MessageReceived += session.MessageReceived;
}
else
@ -269,7 +276,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
{
if (sessions.hasUserGuildSession(guildId, clientId))
{
PublicSession session = sessions.getSession(clientId, guildId);
PublicSession session = sessions.getSession(guildId, clientId);
await disconnectSession(guildId, clientId);
await deletePublicChannel(session);
unregisterSession(session);
@ -294,7 +301,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
{
if (sessions.hasUserGuildSession(guildId, clientId))
{
PublicSession session = sessions.getSession(clientId, guildId);
PublicSession session = sessions.getSession(guildId, clientId);
if(session.isConnected())
{
await session.disconnect(true);
@ -322,7 +329,7 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
{
if(sessions.hasUserGuildSession(guildId, clientId))
{
PublicSession session = sessions.getSession(clientId, guildId);
PublicSession session = sessions.getSession(guildId, clientId);
await session.reconnect();
return true;
}
@ -342,13 +349,13 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
protected EmbedBuilder buildPermssionCard(Permission permission)
{
EmbedBuilder embeddedBuilder = new EmbedBuilder();
embeddedBuilder.AddInlineField("Created By", "<@" + permission.createdByClientID + ">");
embeddedBuilder.AddInlineField("Date created", permission.createdAt.ToString("d.MM.yyyy HH:mm:ss zzz \"UTC\" "));
embeddedBuilder.AddField("Created By", "<@" + permission.createdByClientID + ">", true);
embeddedBuilder.AddField("Date created", permission.createdAt.ToString("d.MM.yyyy HH:mm:ss zzz \"UTC\" "), true);
embeddedBuilder.AddField("Assigned role", "<@&" + permission.roleId + ">");
embeddedBuilder.AddInlineField("Role rights", permission.userPrivilege.ToString());
embeddedBuilder.AddInlineField("1: Create session", permission.canCreateSessions);
embeddedBuilder.AddInlineField("2: Partake session", permission.canParticipateSession);
embeddedBuilder.AddInlineField("3: Enter session. chan.", permission.canViewSessions);
embeddedBuilder.AddField("Role rights", permission.userPrivilege.ToString(), true);
embeddedBuilder.AddField("1: Create session", permission.canCreateSessions, true);
embeddedBuilder.AddField("2: Partake session", permission.canParticipateSession, true);
embeddedBuilder.AddField("3: Enter session. chan.", permission.canViewSessions, true);
embeddedBuilder.WithColor(client.GetGuild(permission.guildId).GetRole(permission.roleId).Color);
embeddedBuilder.WithDescription("Permission entry");
@ -363,9 +370,9 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
foreach (Permission permission in permList)
{
embeddedBuilder.AddInlineField("Assigned role", "<@&" + permission.roleId + ">");
embeddedBuilder.AddInlineField("Created By", "<@" + permission.createdByClientID + ">");
embeddedBuilder.AddInlineField("Role rights", permission.userPrivilege.ToString());
embeddedBuilder.AddField("Assigned role", "<@&" + permission.roleId + ">", true);
embeddedBuilder.AddField("Created By", "<@" + permission.createdByClientID + ">", true);
embeddedBuilder.AddField("Role rights", permission.userPrivilege.ToString(), true);
}
embeddedBuilder.WithColor(new Color(0x00A0DC));
@ -571,9 +578,9 @@ namespace Omegle_Discord_Bot.Modules.OmegleModule
EmbedBuilder embeddedBuilder = new EmbedBuilder();
sessions.iterateByGuildId(context.Guild.Id, (PublicSession session) =>
{
embeddedBuilder.AddInlineField("Created By", "<@" + session.owner.Id + ">");
embeddedBuilder.AddInlineField("Date created", session.createdAt.ToString("d.MM.yyyy HH:mm:ss zzz \"UTC\" "));
embeddedBuilder.AddInlineField("Session type: ", session.type.ToString());
embeddedBuilder.AddField("Created By", "<@" + session.owner.Id + ">", true);
embeddedBuilder.AddField("Date created", session.createdAt.ToString("d.MM.yyyy HH:mm:ss zzz \"UTC\" "), true);
embeddedBuilder.AddField("Session type: ", session.type.ToString(), true);
});
if(embeddedBuilder.Fields.Count>0)
{

4
Omegle-Discord-Bot/Omegle-Discord-Bot.csproj

@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="1.0.2-build-00800" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.8-dmr" />
<PackageReference Include="Discord.Net" Version="2.0.0-beta-00875" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.9-dmr" />
</ItemGroup>
<PropertyGroup>