Exemplo n.º 1
0
    public async Task SendSteam(string mention = null)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        if (mention == null)
        {
            string steamID64 = LinkedSignatures.GetSteam(Context.Message.Author.Id.ToString());

            //If account not linked
            if (steamID64 == null)
            {
                await ReplyAsync("Your Discord isn't linked to a Steam profile. Run !link."); return;
            }
            //If account is linked
            await ReplyAsync($"Here's the profile you're looking for\nhttps://steamcommunity.com/profiles/{steamID64}");
        }
        else
        {
            string steamID64 = LinkedSignatures.GetSteam(Utilities.GetDID(mention));

            //If account not linked
            if (steamID64 == null)
            {
                await ReplyAsync("Their Discord isn't linked to a Steam profile. You can ask them to run !link."); return;
            }
            //If account is linked
            await ReplyAsync($"Here's the profile you're looking for\nhttps://steamcommunity.com/profiles/{steamID64}");
        }

        await Utilities.StatusMessage("steam", Context);
    }
Exemplo n.º 2
0
    public async Task SendGang(string mention = null)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        if (mention == null)
        {
            string steamID64 = LinkedSignatures.GetSteam(Context.Message.Author.Id.ToString());
            await ReplyAsync($"{Context.Message.Author.Mention} is in {await Utilities.GetGang(steamID64)}");
        }
        else
        {
            string dID       = mention.Replace("<@!", "").Replace(">", "");
            string steamID64 = LinkedSignatures.GetSteam(dID);
            await ReplyAsync($"<@!{dID}> is in gang: {await Utilities.GetGang(steamID64)}");
        }
        await Utilities.StatusMessage("bind", Context);
    }
Exemplo n.º 3
0
    public async Task LinkAccount()
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        if (LinkedSignatures.GetSteam(Context.Message.Author.Id.ToString()) != null)
        {
            await Context.Channel.SendMessageAsync("Account already linked"); return;
        }

        var u = Context.Message.Author;

        byte[] idBytes = Encoding.UTF8.GetBytes(u.Id.ToString());
        Console.WriteLine(idBytes);
        string encodedID = Convert.ToBase64String(idBytes);

        await Discord.UserExtensions.SendMessageAsync(u, $"Click here to link your account: https://nickgor.com/SteamAuth.php?DiscordID={Reverse(encodedID)}");

        await ReplyAsync("Check your DMs");
    }
    public async Task AssignRoles()
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        foreach (var member in Context.Guild.Users)
        {
            if (!member.IsBot)
            {
                string steamID64 = LinkedSignatures.GetSteam(member.Id.ToString());
                string gang      = await Utilities.GetGang(steamID64);

                var role = Context.Guild.Roles.FirstOrDefault(x => x.Name == gang);
                if (role != null)
                {
                    await member.AddRoleAsync(role);
                    await ReplyAsync($"{member.Username} has been assigned to {gang}");
                }
                else
                {
                    if (gang != "No Gang yet.")
                    {
                        await Context.Guild.CreateRoleAsync(gang, null, Discord.Color.Blue, false, null);

                        await member.AddRoleAsync(role);
                        await ReplyAsync($"{member.Username} has been assigned to {gang}");
                    }
                }
            }
        }

        //await Context.Channel.SendMessageAsync($"{Context.Message.Author.Mention} rolled `{roll}`");
        await Utilities.StatusMessage("autoassign", Context);
    }
    public async Task SendSignature([Remainder] string id = null)
    {
        byte[] sig;
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        //Gets the current users signature
        if (id == null)
        {
            string steamID64 = LinkedSignatures.GetSteam(Context.Message.Author.Id.ToString());
            if (steamID64 == null)
            {
                await Context.Channel.SendMessageAsync($"Your Discord isn't linked to a Steam profile. To link your account, run !link");

                await Utilities.StatusMessage("signature", Context);

                return;
            }
            else
            {
                var msg = await ReplyAsync("Obtaining signature");

                using (WebClient wc = new WebClient())
                {
                    sig = await wc.DownloadDataTaskAsync(new Uri(Utilities.GetSignature(steamID64)));
                }
                string path = $"{Utilities.RandomString(8)}.png";
                await File.WriteAllBytesAsync(path, sig);

                await Context.Channel.SendFileAsync(path, "Here's the signature you were looking for:");

                File.Delete(path);
                await msg.DeleteAsync();

                await Utilities.StatusMessage("signature", Context);

                return;
            }
        }

        //Gets the signature of a mentioned user
        else if (id.StartsWith("<"))
        {
            string steamID64 = LinkedSignatures.GetSteam(Utilities.GetDID(id));
            if (steamID64 == null)
            {
                await Context.Channel.SendMessageAsync($"Their Discord isn't linked to a Steam profile.");

                await Utilities.StatusMessage("signature", Context);

                return;
            }
            else
            {
                var msg = await ReplyAsync("Obtaining signature");

                using (WebClient wc = new WebClient())
                {
                    sig = await wc.DownloadDataTaskAsync(new Uri(Utilities.GetSignature(steamID64)));
                }
                string path = $"{Utilities.RandomString(8)}.png";
                await File.WriteAllBytesAsync(path, sig);

                await Context.Channel.SendFileAsync(path, "Here's the signature you were looking for:");

                File.Delete(path);
                await msg.DeleteAsync();

                await Utilities.StatusMessage("signature", Context);

                return;
            }
        }

        //Gets the signature of the specified steamID
        else
        {
            if (id.StartsWith("STEAM") || id.StartsWith("7656"))
            {
                var msg = await ReplyAsync("Obtaining signature");

                using (WebClient wc = new WebClient())
                {
                    sig = await wc.DownloadDataTaskAsync(new Uri(Utilities.GetSignature(id)));
                }
                string path = $"{Utilities.RandomString(8)}.png";
                await File.WriteAllBytesAsync(path, sig);

                await Context.Channel.SendFileAsync(path, "Here's the signature you were looking for:");

                File.Delete(path);
                await msg.DeleteAsync();

                await Utilities.StatusMessage("signature", Context);
            }
            else
            {
                await ReplyAsync("Specified input is not a valid SteamID/SteamID64");

                await Utilities.StatusMessage("signature", Context);
            }
        }
    }