requests.py 1.0 KB

12345678910111213141516171819202122232425
  1. from server.jrequest.request_type import request_type
  2. import discord
  3. import json
  4. """
  5. This file defines the output/style of bot messages,
  6. from requests received from the SA:MP server.
  7. """
  8. # Stock/Default request types (ones that are reused)
  9. @request_type
  10. async def basic_player(server, data):
  11. #Set title (with player name appended), description and colour of the embed.
  12. embed = discord.Embed(title=data['title'] + " " + data['player'], description=data['message'], color=discord.Colour(int(data['color'])))
  13. #Set time as footer
  14. embed.set_footer(text=data['time'])
  15. #Send the embedded message to the specified channel
  16. await server.bot.send_message(discord.Object(id=data['channel']), embed=embed)
  17. @request_type
  18. async def basic(server, data):
  19. print("Invoking basic request output to Discord...")
  20. embed = discord.Embed(title=data['title'], description=data['message'], color=discord.Colour(int(data['color'])))
  21. embed.set_footer(text=data['time'])
  22. await server.bot.send_message(discord.Object(id=data['channel']), embed=embed)