Code Monkey home page Code Monkey logo

unity-discord-webhook-system's Introduction

Unity-Discord-Webhook-System

A simple script for sending webhooks with embedded files to Discord from Unity

Quickstart

  • 1: Simply add this script to a unity project
  • 2: Change the values in the default static strings at the top of the script to the appropriate vaules for your use case
  • 3: Test setup by clicking Tools/Discord/Test
  • 4: Begin calling functions from other scripts such as Discord.Send("Hello world!")

Check the other functions below for info

About

I created this script primarily to send crash reports and analytics back to me on Discord so I can improve my Unity games with data collection. The script was created with reference to http://www.briangrinstead.com/blog/multipart-form-post-in-c a great blog post showing the basics of how to use multi form post requests.

Usage

Feel free to use this script how ever you like, It is easy to impliment and allows you to instantly start tracking client data easily. It can also be used to add notifications etc. for players but I recommend only calling the functions in menus etc. to avoid slowing down the game or causing it to hang.

Functions

Simple message functions and parameters

  • Discord.Send(string mssgBody)
  • Discord.Send(string mssgBody, string userName)
  • Discord.Send(string mssgBody, string userName, string webhook)

File sharing message functions and parameters

  • SendFile( string mssgBody, string filename, string fileformat, string filepath, string application)

  • SendFile( string mssgBody, string filename, string fileformat, string filepath, string application, string userName)

  • SendFile( string mssgBody, string filename, string fileformat, string filepath, string application, string userName, string webhook)

Notes

  • When sending data files I recommend setting the application string to "application/msexcel" in order to default it to open in excel
  • File format does not include the dot example "csv" or "txt"
  • File path is the fully qualified file path
  • File name includes file type example "file.csv" or "data.txt"
  • Remember discord will rate limit you if you send too many requests
  • IMPORTANT! in order to prevent your game from hanging I recommend you call the script functions as tasks like this, remembering to declare the namespace being used:
Task.Factory.StartNew(() => Send("Test"));

https://morgan.games/

unity-discord-webhook-system's People

Contributors

morganskilly avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.