Who is using FP Discord? | Promotion Forum

download discord | Black Hat Seo and Affiliate Marketing Forum

Press the "Download now" button to download discord installer
The whole process will only take a few minutes.

[​IMG]

Mirror link —> DISCORD DOWNLOAD

– Title: discord
– Type of download: security (without torrent / without virus)
– Status file: clean (as of the last analysis)
– File size: undefined
– Price: free
– Special requirements: do not

[​IMG]

[​IMG]

[​IMG]

Download Discord for Windows, macOS, Linux and on your iOS or Android
device.
Improve your game with a modern voice and text chat application. Crystal clear voice
Support for multiple servers and channels, mobile applications and more.
3 days ago Download Discord. All-in-one text and voice chat for players is free, safe,
and it works both on your desktop and on your phone. Stop paying for
Discordia, free and safe download. Discordia latest version: chat with friends, family
and playmates, for free. Discordia – Chat for Gamers is watching an impressive
March 13, 2019 Download Discord for Windows PC from FileHorse. 100% safe and secure ✓
Free download (32 bits / 64 bits) Last version 2019.
February 2, 2019 You only know Skype and you speak well of it until you get in touch with Discord.
You will not opt ​​for any other chat service. It comes with a text
Download Discord 0.0.301 for Windows. Get great voice communications and
Text chat absolutely free while you play with Discord.
August 19, 2016 All-in-one text and voice chat for players is free, secure and works on both.
Your desk and telephone. Discord is always completely free of
Discordia – Downloads
Discord – Free text and voice chat for players
Download Discord 5.14.2018 – TechSpot
Discord – Download
Discord Download (2019 most recent) for Windows 10, 8, 7 – FileHorse
Free discord download for Windows 10, 7, 8 / 8.1 (64 bit / 32 bit)
Download Discord 0.0.301 (free) for Windows
Discordia – Free download and software reviews – CNET Download.com
https://discordapp.com/download
https://discordapp.com/
https://www.techspot.com/downloads/6871-discord.html
https://discord.en.softonic.com/
https://www.filehorse.com/download-discord/
https://softfamous.com/discord/
http://downloads.tomsguide.com/Discord,0301-63775.html
https://download.cnet.com/Discord/3000-2349_4-77345258.html
discharge of discord
Windows 10 for Mac download
download unlocked fortnita
hide all ip free download
ms office 2016 mac download
Showbox download application for Android
download flash player free
download gta 5 mobile
mobile sims download
Top 40 mp3 download free
download of the virtual machine
download gta vice city for free
download capitane marvel movie
htc one m7 firmware download
Download free blender video editor
download gta 5 mobile apk
download rock n roll free
gta san andreas download
Windows Media Player download for Windows 8
free download of internet security software

Question – I connected to the discord | Promotion Forum

python – How to make my discord bot if it disconnects from the voice channel?

I'm creating a discord bot, but the discord.py library has updated and is giving an error when trying to disconnect. How to solve? `Import discord
class MyClient (discord.Client, discord.VoiceClient):
async def on_ready (self):
print (& # 39; Bot Online & # 39 ;, self.user)
(in case it is not in the list of commands. nTwitch of the creator of the bot: https://twitch.tv/r3d_g4m3r_ & # 39;))
print (& # 39; Status changed! & # 39;)
async def on_member_join (self, member):
guild = member.guild
if the guild.system_channel is none:
(in the case of a person who is not of your family).
waitit guild.system_channel.send (to_send)
async def on_message (self, message):
# do not respond to ourselves
if the message.author == self.user:
he came back

                if it is.content == & # 39 ;! rules & # 39;
wait message.channel.send ("" "

====== ====== NORMS
1.No flood
2. Otakus are not allowed in that group
3.The @ Never # 0546 eh horn
====== ====== NORMS
"" ")
If the message is & # 39; = & # 39; & # 39; commands & # 39;
wait message.channel.send ("" "
====== ====== COMMANDS
! rules
! commands
horns!
====== ====== COMMANDS
"" ")

                if message.content.startswith (& # 39 ;! horns & # 39;):
wait message.channel.send ("" "

====== ====== Horns
DONO: @Lucas Hiesttiefer # 7152
VICE: @ RedinXD # 3473
ADMS: @ calanguin123 # 7506 @ Never # 0546
====== ====== Horns
"" ")

                if message.content.startswith (& # 39 ;! enter & # 39;):
Suppliers:
channel = await message.author.voice.channel.connect ()
with the exception of:
(in the case of a channel).

if message.content.startswith (& # 39 ;! quit & # 39;):
await self.disconnect (discord.VoiceClient.is_connected ())

client = MyClient ()

with open (& # 39; token & # 39 ;, & # 39; r & # 39;) the fd:
= Counter fd.read ()
fd.close ()
client.run (token) & # 39;

Tools – I would like to simulate an Anima dice: Beyond fantasy in Rolisteam dice roll in Discord. Can I do that, and if so, how?

As I'm sure anyone who has played knows, Anima has interesting dice behaviors.

Manually tracking them is a kind of pain in the neck, so I was wondering if there was a way to implement them as a single action in this dice analyzer, on Discord. (My campaign currently uses this dice analyzer, although if this dice analyzer can not be used, and a different Data analyzer or dice application (for example, rolz.org) can, that would be something that could be configured.)

The behaviors they are. necessary for this answer:

  1. The die, a d100, explodes in a 90, which then explodes in a 91, which then explodes in a 92, etc., up to 100, when it will continue to explode in 100 s.
  2. The die fumbles at the other end of the range, using a past argument, since the range of fumble in Anima can vary, under normal circumstances, between 2 and 5. (In extraordinary circumstances, it can vary between 1 and 5). the performance of a fumble depends on you, but you must handle at least one fumble in attack / defense (subtract 1d100 from your roll, which makes do not explode), and a loose ball in the skills (compare a result of d100 with a table). I will not need the + -15 thing in the central rule book, since it has several problems as to exactly how it is supposed to work.
  3. Preferably, adding arbitrary modifiers to the result should be easy to do.

Additional bonus points (no particular value) will be awarded for implementing the luck manipulation powers in Prometheum Exxet as options, which are the following and can be combined:

Option A: the dice explodes on any doubles roll (11, 22, 33, … 99)

Option B: the dice explodes from 85, instead of 90.

Screen sharing in any software (Discord, Skype, etc.) no longer works

I installed Greenshot and when I tried to share the screen in Discord, Discord got locked. I thought it was because Greenshot uninstalled it, but Discord still fails. Tested in other software with the same results.

python – Convert words / numbers in Discord "letter / number emojis"

Disclaimer: I do not know anything about these "letters of discord"

Organization of the code

You could rearrange your code so that the units are easier to use independently.

The easiest thing is to rewrite the discord Function to return a value instead of updating a global variable.

Another thing to do is put all the Tkinter logic in a function. Usually, that function that really does things would be behind a yes __name__ == "__main__" Guard.

We would have

# the function to convert a string to "letters of discord"
def convert_to_discord_letters (word):
# A list in which converted Charts are stored is used later to generate the converted Charts in a text box
result = []
    # List of numbers from 0 to 9, used to check the string for numbers and then convert them
# a "Discord Digits" since they have a different syntax in discord than Letters
characters = set (& # 39; 0123456789 & # 39;)
s = {& # 39; a & # 39 ;, & # 39; b & # 39 ;, & # 39 ;, & # 39; d & # 39 ;, & # 39; e & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39; k & # 39 ;, & # 39; l & # 39; , & # 39 ;, & # 39 ;, & # 39 ;, & & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, r & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39; v & # 39 ;,
& # 39; W x Y Z & # 39;}
# In case the user enters spaces, these are eliminated since they only cause problems
word = word.replace ("", "")
word = word.lower ()
w = word
for i in range (len (w)):
# check if the string has a number and results
if there are ((c in characters) for c in w[i]):
list_one = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]
            result.append (& # 39;: & # 39; + list_one[int(w[int(w[int(w[int(w[i])]+ ":" + "")
# check if the string has letter and results accordingly (it may not be necessary)
elif anyone ((c on s) for c in w[i]):
result.append (& # 39 ;: regional_indicator _ & # 39; + w[i] + ":" + "")
plus:
# In case the user enters something incorrect.
print ("false entry")
# print (result)
return result



# defines the click function that is called when you press the submitButton1
click on ():
# saves the text that is entered in the text box, which is then converted to "Discord letters"
enter_text = textentry.get ()
# delete the output box in case the user presses the button again to convert something new
output.delete (1.0, END)
# the function to convert a string to "letters of discord"
result = convert_to_discord_letters (ingres_text)
# loop that gets the length of the string written in the text box and then sends it to the output text box
for i in range (len (ingres_text)):
output.insert (END, result[i])

# defines the click function that is called when you press the submitButton1
click on ():
# saves the text that is entered in the text box, which is then converted to "Discord letters"
enter_text = textentry.get ()
# delete the output box in case the user presses the button again to convert something new
output.delete (1.0, END)
# the function to convert a string to "letters of discord"
result = convert_to_discord_letters (ingres_text)
# loop that gets the length of the string written in the text box and then sends it to the output text box
for i in range (len (ingres_text)):
output.insert (END, result[i])


def tkinter_discord_letter_converter ():
root = Tk ()
root.title ("Discord Letter Converter")
# Text entry
textentry = Input (root, width = 20, bg = "white")
textentry.pack ()
# send button
submitButton1 = Button (root, text = "Submit", width = 6, command = click) #
submitButton1.pack ()
# TextOutput
output = Text (root, width = 75, height = 6, adjustment = WORD, background = "white")
output.pack ()
root.mainloop ()



yes __name__ == & # 39; __ main __ & # 39;
tkinter_discord_letter_converter ()

Note: I have not tried this because I do not have Tkinter, but I have tried parts of its code because I have …

Unit tests

Now that the code is reorganized, we can easily write small tests for the discord function that I have changed names test_convert_to_discord_letters

def test_convert_to_discord_letters ():
"" "Test function convert_to_discord_letters." ""
# TODO: This could / should use a proper unit test frame
# Empty box
affirm convert_to_discord_letters ("") == []
    # Blank space
affirm convert_to_discord_letters ("") == []
    # Special characters
affirm convert_to_discord_letters ("# ~ & $ £ ()[]") == []
    # Lowercase letters
claim convert_to_discord_letters ("abcz") == [':regional_indicator_a: ', ':regional_indicator_b: ', ':regional_indicator_c: ', ':regional_indicator_z: ']
    # Capital letters
affirm convert_to_discord_letters ("ABCZ") == [':regional_indicator_a: ', ':regional_indicator_b: ', ':regional_indicator_c: ', ':regional_indicator_z: ']
    # Digits
affirm convert_to_discord_letters ("42") == [':four: ', ':two: ']
    # Mix
affirm convert_to_discord_letters ("Bar -_- 9") == [':regional_indicator_b: ', ':regional_indicator_a: ', ':regional_indicator_r: ', ':nine: ']

Getting better test_convert_to_discord_letters

Now that we have unit tests for the function, we can try to improve it more safely without breaking its behavior.

Loop like a native

I highly recommend Ned Batchelder's "Loop like a native" talk about iterators. One of the simplest options is that whenever you are ranking (len (iterabme)), you can probably do things in a better way: more concise, clearer and more efficient.

In your case, this gives:

                for char in w:
# check if the string has a number and results
if any ((c in characters) for c in char):
list_one = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]
            result.append (& # 39;: & # 39; + list_one[int(char)] + ":" + "")
# check if the string has letter and results accordingly (it may not be necessary)
elif any ((c in s) for c in char):
result.append (& # 39 ;: regional_indicator _ & # 39; + char + ":" + "")
plus:
# In case the user enters something incorrect.
pass # print ("false entry")

So, some things seem more obvious:

  • we do not really need the w variable. In addition, several reassignments of word They are not necessary
  • variations of any ((c in XXX) for c in char) look weird once we realize that char It is a single character. We could write this: yes char in xxx
  • The variable characters it would be better named digits While s it would be better named letters

In this stage, we have

# the function to convert a string to "letters of discord"
def convert_to_discord_letters (word):
# A list in which converted Charts are stored is used later to generate the converted Charts in a text box
# List of numbers from 0 to 9, used to check the string for numbers and then convert them
# a "Discord Digits" since they have a different syntax in discord than Letters
digits = set (& # 39; 0123456789 & # 39;)
letters = {& # 39; a & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39; e & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39; k & # 39 ;, & # 39; l & # 39; , & # 39 ;, & # 39 ;, & # 39 ;, & & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, r & # 39 ;, & # 39 ;, & # 39 ;, & & # 39 ;, & # 39 ;, & # 39 ;, & # 39 ;, & # 39; w & # 39 ;, & # 39; x & # 39 ;, & # 39; and & # 39 ;, & # 39; z & # 39;
result = []
    for char in word.replace ("", "") .lower ():
# check if the string has a number and results
If the characters are in characters:
list_one = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]
            result.append (& # 39;: & # 39; + list_one[int(char)] + ":" + "")
# check if the string has letter and results accordingly (it may not be necessary)
elif char in letters:
result.append (& # 39 ;: regional_indicator _ & # 39; + char + ":" + "")
plus:
# In case the user enters something incorrect.
pass # print ("false entry")
# print (result)
return result

Definitions of the data used.

For lyrics, you could use ascii_lowercase since rope module:

import chain
...
letters = set (string.ascii_lowercase)

For the digits, define a set and a list, convert the value to integer to obtain the string in the relevant index. It seems that the best data structure to use would be a single diction of digits of chain mapping.

                digits = {"0": "zero", "1": "one", "2": "two", "3": "three", "4": "four", "5": "five" , "6": "six", "7": "seven", "8": "eight", "9": "nine"}

Useless string literal concatenations.

":" + "" it can be written ":".

In this stage, we have:

# the function to convert a string to "letters of discord"
def convert_to_discord_letters (word):
# A list in which converted Charts are stored is used later to generate the converted Charts in a text box
# List of numbers from 0 to 9, used to check the string for numbers and then convert them
# a "Discord Digits" since they have a different syntax in discord than Letters
digits = {"0": "zero", "1": "one", "2": "two", "3": "three", "4": "four", "5": "five" , "6": "six", "7": "seven", "8": "eight", "9": "nine"}
letters = set (string.ascii_lowercase)
result = []
    for char in word.replace ("", "") .lower ():
# check if the string has a number and results
If the characters are in characters:
result.append (& # 39;: & # 39; + digits[char] + ":")
# check if the string has letter and results accordingly (it may not be necessary)
elif char in letters:
result.append (& # 39 ;: regional_indicator _ & # 39; + char + ":")
plus:
# In case the user enters something incorrect.
pass # print ("false entry")
print (result)
return result

And we realize that most comments are no longer necessary because the code is much clearer. On the other hand, we could add a string of appropriate documentation.

def convert_to_discord_letters (word):
"" "Convert a string to a list of strings corresponding to" Discord Letters "." ""
digits = {"0": "zero", "1": "one", "2": "two", "3": "three", "4": "four", "5": "five" , "6": "six", "7": "seven", "8": "eight", "9": "nine"}
letters = set (string.ascii_lowercase)
result = []
    for char in word.replace ("", "") .lower ():
If the characters are in characters:
result.append (& # 39;: & # 39; + digits[char] + ":")
elif char in letters:
result.append (& # 39 ;: regional_indicator _ & # 39; + char + ":")
plus:
pass # TODO: I'll let you decide how to handle other cases
return result

Plus

I suspect that the click The feature could benefit from the same ideas, but you can not try it at this time.

In addition, the code seems to assume that text_entracted Y result will have the same length that may not be the case for unmanaged characters.

Get 20 discord invitations to your server for $ 3

Why do you need to buy the Discord server?

  • Discord is a web service (and client) that allows people to connect through chat and voice.
  • For companies and a general center for any type of community.
  • For startups and anyone trying to grow a community.

Why baddhidurgarao is the best place to buy Discord invitations:

  • A discord server
  • Some bots to automate and moderate your server.
  • Approximately 3 days delivery


This service has no qualifications – order and leave first!


$3In stock

.

Discord + ffmpeg (v4l2loopback) Using custom camera input

I am trying to send custom video sequences to the discord through a virtual camera device with the following command:

ffmpeg -i http://192.168.2.130:8080/video -vf "transpose = 1" -pix_fmt yuv420p -f v4l2 / dev / video2

I am able to access the camera through vlc successfully. But the device is not shown in the Discordias configuration.

I guess this is something that has to do with the Discord de Electron framework, missing some configuration that says "Hey, I'm a camera too" or something similar.

I ask how do I solve this problem?

python – Discord bot that queries an external API

I'm posting here to ask for help to improve my use of Python, since I'm pretty new at that and I come from C #.

The main functionality of this bot is to analyze the Wargaming API to obtain information related to the player.

Structure of the project:

draft
| main.py
└───ENV
│
└───data
| classes.py
| dbcontext.py
| getStats.py

My main:

import asyncio
Import registration
import os
import systems
import re
import json

import discord
from discord.ext import commands

from data import dbcontext, log, secret, getStats as GetStats
of data.translations import in, of, pl, tr
from data.classes import Config, Ship, Player, Stats, ReturnVal, ErrorType

sys.path.append (os.path.join (os.path.dirname (__ file__), "data"))


""
WoWs-Stats Bot.
Creator Fuyune

Use Discord.py framework by Rapptz
""

####### Bot Basic Configuration #######

bot = commands.Bot (command_prefix = "!")
logger = logging.getLogger (& # 39; discord & # 39;)
logger.setLevel (logging.ERROR)
handler = logging.FileHandler (filename = & # 39; err.log & # 39 ;, encoding = & # 39; utf-8 & # 39 ;, mode = & # 39; a & # 39;)
handler.setFormatter (logging.Formatter (
& # 39;% (asctime) s:% (levelname) s:% (name) s:% (message) s & # 39;)
logger.addHandler (handler)
bot.remove_command (& # 39; help & # 39;)
configs = []
regions = ["eu","ru","na","asia"]
langs = ["de","en","pl","tr"] #remember adding to imports too
amounts = {}

####### Bot Events #######

@ bot.event
async def on_ready ():
log.writeLog ("init", "Ready")
print ("Bot Started")
configs = []
    for x in bot.guilds:
configs.append (dbcontext.getConfig (x.id))
print ("Connected to:" + x.name)
log.writeLog ("Connected", x.name)


@ bot.command ()
async def stats (ctx, * args):
if ctx.message.guild is None:
await ctx.send ("** I can not reply in private messages. **")
plus:
config = dbcontext.getConfig (ctx.guild.id)
if (len (args) == 0) or (len (args) == 1 and args[0].lower () == "help"):
awaits writeHelp (ctx, config)
elif len (args) == 1 and args[0] ! = "help":
playerObject = GetStats.getPlayer (config, args[0])
if playerObject == None or playerObject.id == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_PLAYER)
plus:
playerStats = GetStats.getPlayerStats (config, playerObject)
yes playerStats.hidden:
awaits writeError (ctx, config, ErrorType.HIDDEN_STATS)
elif playerStats.damage == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_STATS)
plus:
awaits writeAnswer (ctx, config, playerObject, playerStats)
elif len (args)> = 2:
playerObject = GetStats.getPlayer (config, args[0])
if playerObject == None or playerObject.id == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_PLAYER)
plus:
ship = dbcontext.getShip ("" .join (args[1:]))
if ship.id == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_SHIP)
plus:
shipStats = GetStats.getShipStats (config, playerObject, ship)
if shipStats.hidden:
awaits writeError (ctx, config, ErrorType.HIDDEN_STATS)
elif shipStats.damage == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_STATS)
plus:
awaits writeAnswer (ctx, config, playerObject, ship, shipStats)


@ bot.command ()
async def statsr (ctx, * args):
if ctx.message.guild is None:
await ctx.send ("** I can not reply in private messages. **")
plus:
config = dbcontext.getConfig (ctx.guild.id)
regex = re.compile ("^ (![1-9][1]|[1-9]) | (! s[1-4]) $ ", re.IGNORECASE) # regex to verify the valid season
if (len (args) == 0) or (len (args) == 1 and args[0].lower () == "help"):
awaits writeHelp (ctx, config)
elif regex.match (args[0]):
awaits writeError (ctx, config, ErrorType.UNKNOWN_SEASON)
elif len (args) == 2 and args[0] ! = "help":
season = convertSeason (args[0])
playerObject = GetStats.getPlayer (config, args[1])
if playerObject == None or playerObject.id == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_PLAYER)
plus:
playerStats = GetStats.getRankedStats (config, playerObject, season)
yes playerStats.hidden:
awaits writeError (ctx, config, ErrorType.HIDDEN_STATS)
elif playerStats.damage == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_STATS)
plus:
awaits writeAnswer (ctx, config, playerObject, playerStats)
elif len (args)> 2:
season = convertSeason (args[0])
playerObject = GetStats.getPlayer (config, args[1])
if playerObject == None or playerObject.id == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_PLAYER)
plus:
ship = dbcontext.getShip ("" .join (args[2:]))
if ship.id == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_SHIP)
plus:
shipStats = GetStats.getRankedStats (config, playerObject, season, ship)
if shipStats.hidden:
awaits writeError (ctx, config, ErrorType.HIDDEN_STATS)
elif shipStats.damage == 0:
awaits writeError (ctx, config, ErrorType.UNKNOWN_STATS)
plus:
awaits writeAnswer (ctx, config, playerObject, ship, shipStats)
plus:
awaits writeHelp (ctx, config)

####### Help functions #######

async def writeAnswer (ctx, config, * args):
player = none
Ship = None
stats = none
embed = None
translation = global ()[config.language]
    for arg in args:
If it is an instance (arg, player):
player = arg
elif isinstance (arg, Ship):
ship = arg
elif isinstance (arg, statistics):
stats = arg
if player! = None and stats! = None and ship! = None:
color = getColor (stats.avgWins)
embed = discord.Embed (title = translation.title.format (username = player.name), url = GetStats.getPlayerLink (config, player), description = translation.description.format (shipname = ship.name), color = color )
embed.set_author (name = "WoWs-Stats-Bot", url = "https://github.com/De-Wohli")
embed.set_thumbnail (url = ship.url)
embed.add_field (name = translation.battles, value = stats.battles, inline = True)
embed.add_field (name = translation.avgDamage, value = stats.avgDamage, inline = True)
embed.add_field (name = translation.winrate, value = "{:. 2f}%". format (stats.avgWins), inline = True)
embed.set_footer (text = translation.footer)
elif player! = None and stats! = None and ship == None:
color = getColor (stats.avgWins)
embed = discord.Embed (title = translation.title.format (username = player.name), url = GetStats.getPlayerLink (config, player), description = translation.general, color = color)
embed.set_author (name = "WoWs-Stats-Bot", url = "https://github.com/De-Wohli")
embed.add_field (name = translation.battles, value = stats.battles, inline = True)
embed.add_field (name = translation.avgDamage, value = stats.avgDamage, inline = True)
embed.add_field (name = translation.winrate, value = "{:. 2f}%". format (stats.avgWins), inline = True)
embed.set_footer (text = translation.footer)
if embed! = None:
await ctx.send (embed = embed)


async def writeHelp (ctx, config):
color = discord.Color.teal ()
translation = global ()[config.language]
    embed = discord.Embed (title = translation.helpHeader, description = translation.helpDescription, color = color)
embed.set_author (name = "WoWs-Stats-Bot")
embed.add_field (name = "! stats [player]", value = translation.helpPlayer, inline = False)
embed.add_field (name = "! stats [player] [shipname]", value = translation.helpShip, inline = False)
embed.add_field (name = "! statsr [season] [player]", value = translation.helpRanked, inline = False)
embed.add_field (name = "! statsr [season] [player] [shipname]", value = translation.helpSRanked, inline = False)
embed.set_footer (text = "This bot was made by Fuyu_Kitsune")
await ctx.send (embed = embed)


async def writeError (ctx, config, errorType):
color = discord.Color.dark_teal ()
translation = global ()[config.language]
    errorText = traduccion.error[errorType.value]
    embed = discord.Embed (title = "Error", description = errorText, color = color)
embed.set_author (name = "WoWs-Stats-Bot")
embed.set_footer (text = translation.footer)
await ctx.send (embed = embed)


def getColor (value):
yes value <= 40:
        return discord.Colour.red()
    elif value > 40 and value <= 45:
        return discord.Colour.orange()
    elif value > 45 and value <= 50:
        return discord.Colour.gold()
    elif value > 50 and value <= 53:
        return discord.Colour.green()
    elif value > 53 and value <= 56:
        return discord.Color.dark_green()
    elif value > 56 and value <= 60:
        return discord.Color.teal()
    elif value > 60 and value <= 66:
        return discord.Color.purple()
    elif value > 66:
back discord.Colour.dark_purple ()


def convertSeason (value):
season = value
if the season == "s1":
season = "101"
elif season == "s2":
season = "102"
elif season == "s3":
season = "103"
elif season == "s4":
season = "104"
return season

This being the main method, this is where the analysis of the command is carried out. The usual command is ! stats [playername] [shipname] My main concerns here are the async def stats (ctx, * args): Y async def statsr (ctx, * args): functions

data / classes.py:

from enum import enum


boat class
def __init __ (self, id = 0, name = "", url = ""):
self.id = id
self.name = name
self.url = url

def __eq __ (myself, another):
return auto.name == other


Class player:
def __init __ (self, id = 0, name = "", code = "404"):
self.id = id
self.name = name
self.code = code


Class statistics:
def __init __ (self, battles = 0, frags = 0, damage_dealt = 0, wins = 0, hidden = False, code = 404):
self.hidden = hidden
self.battles = battles
self.frags = float (frags)
self.damage = float (damage_dealt)
self.wins = wins
self.code = code

@property
def avFFrags (auto):
yes self.battles == 0:
return 0
round turn (self.frags / self.battles, 2)

@property
def avgDamage (self):
yes self.battles == 0:
return 0
round turn (damage / own damage, 2)

@property
def avgWins (auto):
yes self.battles == 0:
return 0
turn (float (self.wins / self.battles), 4) * 100


Class configuration:
def __init __ (self, serverId = 0, region = "eu", language = "en"):
self.serverId = serverId
self.region = region
own language = language


ReturnVal class (Enum):
SUCCESS = 0
FAILED = 1
DOUBLE = 2

ErrorType class (Enum):
def __str __ (self):
return str (self.value)

UNKNOWN_PLAYER = 0
UNKNOWN_SHIP = 1
UNKNOWN_STATS = 2
HIDDEN_STATS = 3
UNKNOWN_SEASON = 4

These are my model classes, since I come from C # I'm not really sure if this would be an acceptable way to deal with that in Python.

data / dbcontext.py:

import systems
import os
import mysql.connector

import data.log as log
from data.classes import Config, ReturnVal, Ship
of data.secret import Secret


def connect ():
mydb = mysql.connector.connect (host = Secret.dbAddr, user = Secret.dbUser, passwd = Secret.dbPwd, database = Secret.dbName)
returns mydb


def getShip (name):
try:
with = connect ()
cursor = with.cursor ()
sql = & # 39; SELECT id, Name, url FROM Ships WHERE name LIKE% s & # 39;
val = (name,)
cursor.execute (sql, val)
rows = cursor.fetchone ()
if the rows are None:
sql = & # 39; SELECT id, Name, url FROM Ships WHERE id = (SELECT id From Asn WHERE name LIKE% s) & # 39;
val = (name,)
cursor.execute (sql, val)
rows = cursor.fetchone ()
if the rows are None:
boat return ()
plus:
return of the ship (id = rows[0], name = rows[1], url = rows[2])
plus:
return of the ship (id = rows[0], name = rows[1], url = rows[2])
except exception as e:
log.writeLog ("getShip", str (e))
con.rollback ()
boat return ()
Finally:
con.commit ()
con.close ()



def addAsn (name, asn):
try:
with = connect ()
cursor = with.cursor ()
sql = & # 39; SELECT id, Name, url FROM Ships WHERE name LIKE% s & # 39;
val = (name,)
cursor.execute (sql, val)
rows = cursor.fetchone ()
if the rows are None:
return ReturnVal.FAILED
plus:
sql = & # 39; INSERT INTO Asn (name, id, url) VALUES (% s,% s,% s) & # 39;
val = (asn, rows[0]rows[2])
cursor.execute (sql, val)
Returns ReturnVal.SUCCESS
except mysql.connector.IntegrityError as e:
return ReturnVal.DOUBLE
except exception as e:
log.writeLog ("getShip", str (e))
con.rollback ()
return ReturnVal.FAILED
Finally:
con.commit ()
con.close ()

def getConfig (id):
try:
with = connect ()
cursor = with.cursor ()
sql = & # 39; SELECT region, language FROM Config WHERE ServerId =% s & # 39;
val = (id,)
cursor.execute (sql, val)
rows = cursor.fetchone ()
if the rows are None:
config = Config (serverId = id)
sql = & # 39; INSERT INTO Config (ServerID, region, language) VALUES (% s,% s,% s) & # 39;
val = (config.serverId, config.region, config.language)
cursor.execute (sql, val)
return configuration
plus:
Return configuration (serverId = id, region = rows[0], language = rows[1])
except exception as e:
log.writeLog ("getConfig", str (e))
con.rollback ()
Finally:
con.commit ()
con.close ()

def addConfig (id):
try:
with = connect ()
cursor = with.cursor ()
sql = & # 39; INSERT INTO Config (ServerId, region, language) VALUES (% s,% s,% s) & # 39;
val = (id, "eu", "en")
cursor.execute (sql, val)
Returns ReturnVal.SUCCESS
except exception as e:
log.writeLog ("addConfig", str (e))
con.rollback ()
return ReturnVal.FAILED
Finally:
con.commit ()
con.close ()

def updateConfig (config):
try:
with = connect ()
cursor = with.cursor ()
sql = & # 39; UPDATE Config SET region =% s, language =% s WHERE ServerID =% s & # 39;
val = (config.region, config.language, config.serverId)
cursor.execute (sql, val)
Returns ReturnVal.SUCCESS
except exception as e:
log.writeLog ("updateConfig", str (e))
con.rollback ()
return ReturnVal.FAILED
Finally:
con.commit ()
con.close ()

In this file I am handling all access to the database. The database stores mainly the names of the ships and the IDs. Is this way of handling the connection of the secure database or is it vulnerable?

data / getStats.py:

import os
import systems
import requests
import json

sys.path.append (os.path.join (os.path.dirname (__ file__), "lib"))
sys.path.append (os.path.join (os.path.dirname (__ file __), "../data"))
from data.classes import Ship, Player, Stats
of data.secret import Secret
of data.api import api
of the data import record


def getPlayer (config, playerName):
try:
url = api.psearch.format (reg = config.region, wgapi = Secret.api, playerName = playerName)
answer = requests.get (url)
statuscode = response.status_code
answer = answer.json ()
yes the answer["status"] == "ok":
yes the answer["meta"]["count"]    == 0:
Returning player (code = 200)
plus:
nick = answer["data"][0]["nickname"]
                
                
                
                pid = answer["data"][0]["account_id"]
                
                
                
                newPlayer = Player (name = nick, id = pid, code = statuscode)
back newPlayer
plus:
Return player (code = status code)
except exception as e:
print (str (e))
log.writeLog ("getPlayer", str (e))
Returning player (code = 200)


def getPlayerLink (config, player):
link = str.format ("{} {} - {}", str (api.plink) .format (reg = config.region), player.id, player.name)
return link


def getPlayerStats (config, player):
try:
url = api.pstats.format (reg = config.region, wgapi = Secret.api, accountID = player.id)
answer = requests.get (url)
statuscode = response.status_code
answer = answer.json ()
yes (answer["status"] == "ok"):
yes bool (answer["data"]):
yes bool (answer["meta"]["hidden"]):
st = Statistics (1,1,1,1, True, 200)
plus:
battles = answer["data"][str(player.id)]["statistics"]['pvp']['battles']
                    
                    
                    
                    win = answer["data"][str(player.id)]["statistics"]['pvp']['wins']
                    
                    
                    
                    frags = answer["data"][str(player.id)]["statistics"]['pvp']['frags']
                    
                    
                    
                    damage_dealt = answer["data"][str(player.id)]["statistics"]['pvp']['damage_dealt']
                    
                    
                    
                    st = Statistics (battles, fragments, damage_dealt, victories, false, status code)
plus:
Return statistics (code = 200)
back st
plus:
Return statistics (code = status code)
except exception as e:
print (str (e))
log.writeLog ("getPlayerStats", str (e))
Return statistics (code = 200)


def getShipStats (config, player, ship):
try:
url = api.sstats.format (reg = config.region, wgapi = Secret.api, accountID = player.id, shipID = ship.id)
answer = requests.get (url)
statuscode = response.status_code
answer = answer.json ()
yes (answer["status"] == "ok"):
yes bool (answer["meta"]["hidden"]):
st = Statistics (1,1,1,1, True, 200)
elif bool (answer["data"]) and no response["data"][str(player.id)]    == None:
battles = answer["data"][str(player.id)][0]['pvp']['battles']
                
                
                
                win = answer["data"][str(player.id)][0]['pvp']['wins']
                
                
                
                frags = answer["data"][str(player.id)][0]['pvp']['frags']
                
                
                
                damage_dealt = answer["data"][str(player.id)][0]['pvp']['damage_dealt']
                
                
                
                st = Statistics (battles, fragments, damage_dealt, victories, false, status code)
plus:
Return statistics (code = 200)
back st
plus:
Return statistics (code = status code)
except exception as e:
print (str (e))
log.writeLog ("getShipStats", str (e))
Return statistics (code = 200)


def getRankedStats (config, player, season, ship = None):
try:
if the ship is none:
url = api.rsstats.format (reg = config.region, wgapi = Secret.api, accountID = player.id, shipID = ship.id)
plus:
url = api.rpstats.format (reg = config.region, wgapi = Secret.api, accountID = player.id)
answer = requests.get (url)
statuscode = response.status_code
answer = answer.json ()
statistics = statistics ()
yes (answer["status"] == "ok"):
yes bool (answer["meta"]["hidden"]):
Statistics = Statistics (1,1,1,1, True, 200)
elif bool (answer["data"]) and no response["data"][str(player.id)]    == None:
if the ship is none:
stations = answer["data"][str(player.id)][0]["seasons"]
                    
                    
                    
                    If season in seasons:
currentSeason = answer["data"][str(player.id)][0]["seasons"][season]
                    
                    
                    
                    plus:
Return statistics (code = 200)
plus:
stations = answer["data"][str(player.id)]["seasons"]
                    
                    
                    
                    If season in seasons:
currentSeason = answer["data"][str(player.id)]["seasons"][season]
                    
                    
                    
                    plus:
Return statistics (code = 200)
r = []
                r.append (currentSeason)["rank_solo"])
r.append (currentSeason)["rank_div2"])
r.append (currentSeason)["rank_div3"])
for x in r:
if x is none:
stats.wins + = x["wins"]
                        stats.damage + = x["damage_dealt"]
                        stats.battles + = x["battles"]
                        stats.frags + = x["frags"]
                stats.code = 200
plus:
Return statistics (code = 200)
return statistics
plus:
Return statistics (code = status code)
happen
except exception as e:
log.writeLog ("getRankedStats", str (e))
happen

this is the kind of communication to consult the API end points. The endpoints are stored in a different file data / api.py It contains a class with the stored variables. that is to say

api class:
psearch = "https: //api.worldofwarships. {reg} / wows / account / list /? application_id = {wgapi} & search = {playerName}"

The code shown here is currently working and is hosted on a Linux server without too many problems, but I'm curious to know about, probably many things, that could improve
If necessary, I can provide the answers I'm getting from the API if it's something related to the code I've published.

In general, I am looking for help to improve my Python programming and to improve the performance / stability of my code. Any information, as well as criticism is welcome.

Thank you.