Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

General That Is Right, Discord Update Automation in AWS

Martin H Hollstein



Originally posted on Troll Purse Dev Blog

Recently, Troll Purse setup a public invite for the Troll Purse Discord Server. And, as with all things, we decided to test out using Discord Webhooks to push updates to our members in realtime. This is by far the most effective realtime pushing we have conceived yet. It was so easy, sharing it will be just as easy.

Discord Logo

Using A Simple Webhook

Usually, the pattern at Troll Purse to push to third party accounts follows this pattern:

  1. Sign up for the third party account
  2. Register an application
  3. Find an API wrapper library for said third party account
  4. Publish an AWS Lambda
  5. Post about it!

This time, we decided to skip step 3. For the most part, the developers at Troll Purse recognized that this push would require very little data transformation and authentication routines. In fact, all of the work was done in one POST request to the Troll Purse Discord Server.

The Code, Kind Human

public async Task<string> FunctionHandler(SNSEvent input, ILambdaContext context)
        var messageJSONString = input.Records[0]?.Sns.Message;
        context?.Logger.LogLine($"Received({input.Records[0]?.Sns.MessageId}): {messageJSONString}");
        if (messageJSONString != null)
            var messageContent = JsonConvert.DeserializeObject<BlogContentUpdated>(messageJSONString);
            using (var httpClient = new HttpClient())
                string payload = $"{"content":"{messageContent.PostTitle}. {messageContent.ContentSnippet}... {messageContent.PostLink}"}";
                var response = await httpClient.PostAsync(Environment.GetEnvironmentVariable("discord_webhook"), new StringContent(payloadEncoding.UTF8, "application/json"));
                return response.StatusCode.ToString();
            return null;
    catch (Exception e)
        context?.Logger.LogLine("Unable to Discord the SNS message");
        return null;


  • BlogContentUpdated is code defined in an external Troll Purse binary.
  • WE USE SECURE ENVIRONMENT VARIABLES!!! THIS IS IMPORTANT!!!! (As opposed to plaintext credentials in our source code.)

The Joy of Lambda

All of these features that Troll Purse has blogged about are done within a few hours. This is easily aided by the idea of serverless programming. There is no overhead of provisioning servers, testing different server environments, and configuring a network for these functions. It removes a lot of network infrastructure and enables Troll Purse developers to create fast, reactive, internal services.

Please, if you spend too much time configuring and setting up, try using AWS Lambda to speed up development time.

Would You Look At That

In two lines, without a library or API wrapper, our developers can now push blog updates to our Discord server. This is a nice quick feature that we plan on integrating in our automated build environment to push updates about new versions released to the public. Enjoy!

Originally posted on Troll Purse Dev Blog


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!