Skip to content

Commit

Permalink
Merge pull request #2 from Trickyyy/develop
Browse files Browse the repository at this point in the history
1.0.3 merge
  • Loading branch information
Kirollos authored Aug 18, 2019
2 parents 544ee8c + 5f69c68 commit ca86251
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Oxide.Ext.Discord/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class Discord
{
public static List<DiscordClient> Clients { get; private set; } = new List<DiscordClient>();

public static List<string> PendingTokens = new List<string>();

public static void CreateClient(Plugin plugin, string apiKey)
{
if (plugin == null)
Expand Down
18 changes: 18 additions & 0 deletions Oxide.Ext.Discord/DiscordClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ public void Initialize(Plugin plugin, DiscordSettings settings)
throw new APIKeyException();
}

if(Discord.PendingTokens.Contains(settings.ApiToken))
{
Interface.Oxide.LogError($"Connection with same token in short period.. Connection delayed for plugin {plugin.Name}");
Timer t = new Timer() { AutoReset = false, Interval = 5000f, Enabled = true};
t.Elapsed += (object sender, ElapsedEventArgs e) =>
{
Interface.Oxide.LogError($"Delayed connection for plugin {plugin.Name} is being resumed..");
Initialize(plugin, settings);
};
return;
}

RegisterPlugin(plugin);

Settings = settings;
Expand All @@ -75,6 +87,12 @@ public void Initialize(Plugin plugin, DiscordSettings settings)
_webSocket.Connect(WSSURL);
});
Discord.PendingTokens.Add(settings.ApiToken);
Timer t2 = new Timer() { AutoReset = false, Interval = 5000f, Enabled = true };
t2.Elapsed += (object sender, ElapsedEventArgs e) =>
{
Discord.PendingTokens.Remove(settings.ApiToken);
};
}

public void Disconnect()
Expand Down
2 changes: 1 addition & 1 deletion Oxide.Ext.Discord/DiscordExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DiscordExtension(ExtensionManager manager) : base(manager)

public override string Author => "PsychoTea & DylanSMR";

public override VersionNumber Version => new VersionNumber(1, 0, 2);
public override VersionNumber Version => new VersionNumber(1, 0, 3);

public override void OnModLoad()
{
Expand Down
2 changes: 1 addition & 1 deletion Oxide.Ext.Discord/Oxide.Ext.Discord.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<Version>1.0.1.0</Version>
<Version>1.0.3.0</Version>
<AssemblyName>Oxide.Ext.Discord</AssemblyName>
<Authors>PsychoTea</Authors>
<Description>An Oxide extension for Discord.</Description>
Expand Down

0 comments on commit ca86251

Please sign in to comment.