Guest User

Auxi Main Code

a guest
Apr 23rd, 2025
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.51 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. from discord import app_commands
  4. from discord.app_commands import Choice
  5.  
  6. import re
  7. from characterai import PyAsyncCAI
  8. import random
  9. import json
  10.  
  11. from charAI import main
  12. from dados import *
  13.  
  14.  
  15. #DISCORD CONFIG
  16. #region
  17.  
  18. intents = discord.Intents.all()
  19.  
  20. bot = commands.Bot(command_prefix = '.', intents = intents)
  21.  
  22. #endregion
  23.  
  24. #EVENTOS
  25.  
  26.     #Bot se conectou
  27.     #region
  28.  
  29. @bot.event
  30. async def on_ready():
  31.  
  32.     with open('info.json', 'r') as file:
  33.         info = json.load(file)
  34.         canalId = info['canalId']
  35.  
  36.     print(f'{bot.user} se conectou')
  37.     canalGeral = await bot.fetch_channel(canalId)
  38.     await bot.change_presence(activity = discord.Game(name = 'D&D com outros bots'))
  39.     await canalGeral.send('Oie, voltei')
  40.  
  41.     #endregion
  42.  
  43.  
  44.     #Bot se desconectou
  45.     #region
  46.  
  47. @bot.event
  48. async def on_disconnect(ctx):
  49.     await ctx.send('Parece que acabou a sessão, até a próxima!')
  50.  
  51.     #endregion
  52.  
  53.  
  54.     #Comando errado
  55.     #region
  56.  
  57. #@bot.event
  58. # async def on_command_error(ctx, error):
  59. #     await ctx.send(f'O comando "{ctx.message.content}" não existe {ctx.author.name}. Se precisar, digite "/help"')
  60.  
  61.     #endregion
  62.  
  63. #GM
  64.     #SYNC - Sincronizar bot
  65.     #region
  66.  
  67. @bot.command(name = 'sync')
  68. async def sync(ctx):
  69.  
  70.     bot.tree.copy_global_to(guild = ctx.guild)
  71.     await bot.tree.sync(guild = ctx.guild)
  72.  
  73.  
  74.     await ctx.send('sincronizada')
  75.  
  76.     #endregion
  77.  
  78.     #GMFICHA - Ver ficha de alguem
  79.     #region
  80.  
  81. @bot.command(name = 'gmficha')
  82.  
  83. async def gmficha(ctx, jogador : str):
  84.     pass
  85.  
  86.     #endregion
  87.  
  88.     #INVOKE - faz ela vir pro chat em que chamaram o comando
  89.     #region
  90.  
  91. @bot.command(name = 'invoke🔪')
  92. async def invoke(ctx, sacrifice : str = ''):
  93.  
  94.     if not sacrifice.isspace() and sacrifice != '':
  95.         with open('info.json', 'r') as file:
  96.             info = json.load(file)
  97.  
  98.         with open('info.json', 'w') as file:
  99.             info['canalId'] = ctx.channel.id
  100.             json.dump(info, file, indent = 1)
  101.  
  102.         await ctx.send(f'{sacrifice} foi um bom sacrifício, vou atender seu pedido. Agora aviso que eu to online no canal {ctx.channel.name}')
  103.    
  104.     else:
  105.          await ctx.author.send(f'Você não fez nenhum sacrifício {ctx.author.name} 🤨')
  106.  
  107.     #endregion
  108.  
  109.  
  110.  
  111. #JOGADORES
  112.  
  113.     #CRIAR - Cria um personagem
  114.     #region
  115.        
  116. @bot.tree.command(name = 'criar', description = 'Cria um novo personagem')
  117. @app_commands.describe(nome = 'Seu nome',
  118.                        idade = 'Sua idade',
  119.                        gênero = 'Quem por helicoptero de combate será morto na primeira sessão',
  120.                         força = 'Tenha capacidade física',
  121.                         reflexos = 'Reaja rapidamente ao mundo, tenha coordenação motora',
  122.                         inteligência = 'Guarde informação, entenda o mundo e pessoas',
  123.                         resistência = 'Aguente temperaturas extremas, ferimentos e envenenamento',
  124.                         atletismo = 'Use força e velocidade bruta',
  125.                         pegada = 'Segure coisas',
  126.                         nado = 'Nade em líquidos (ou gravidade zero)',
  127.                         arremesso = 'Arremesse objetos (ou pessoas)',
  128.                         percepção = 'Note seus arredores, com sentidos ou intuição',
  129.                         acrobacia = 'Use sua agilidade e equilíbrio',
  130.                         pilotagem = 'Pilote veículos ou animais',
  131.                         jogodmao = 'Manuseie objetos, roube sem ser percebido',
  132.                         furtividade = 'Passe despercebido',
  133.                         conhecimentos = 'Conheça os rumores, guarde informação',
  134.                         enganação = 'Engane os outros, seja o Bruno',
  135.                         infiltração = 'Abra cadeados, invada fortalezas',
  136.                         persuasão = 'Convença pessoas',
  137.                         sobrevivência = 'Sobreviva ao ambiente, seja selva ou concreto',
  138.                         vocações = 'suas profissões, ideais ou objetivos de vida',
  139.                         fraquezas = 'Seus defeitos e fraquezas',
  140.                         riqueza = 'Sua riqueza em geral',
  141.                         destino = 'Quantos pontos do destino você tem')
  142. @app_commands.choices(força = [
  143.     app_commands.Choice(name = '-1', value = -1),
  144.     app_commands.Choice(name = '0', value = 0),
  145.     app_commands.Choice(name = '1', value = 1),
  146.     app_commands.Choice(name = '2', value = 2)
  147. ])
  148. @app_commands.choices(reflexos = [
  149.     app_commands.Choice(name = '-1', value = -1),
  150.     app_commands.Choice(name = '0', value = 0),
  151.     app_commands.Choice(name = '1', value = 1),
  152.     app_commands.Choice(name = '2', value = 2)
  153. ])
  154. @app_commands.choices(inteligência = [
  155.     app_commands.Choice(name = '-1', value = -1),
  156.     app_commands.Choice(name = '0', value = 0),
  157.     app_commands.Choice(name = '1', value = 1),
  158.     app_commands.Choice(name = '2', value = 2)
  159. ])
  160. @app_commands.choices(resistência = [
  161.     app_commands.Choice(name = '-1', value = -1),
  162.     app_commands.Choice(name = '0', value = 0),
  163.     app_commands.Choice(name = '1', value = 1),
  164.     app_commands.Choice(name = '2', value = 2)
  165. ])
  166. @app_commands.choices(atletismo = [
  167.     app_commands.Choice(name = '-1', value = -1),
  168.     app_commands.Choice(name = '0', value = 0),
  169.     app_commands.Choice(name = '1', value = 1),
  170.     app_commands.Choice(name = '2', value = 2)
  171. ])
  172. @app_commands.choices(pegada = [
  173.     app_commands.Choice(name = '-1', value = -1),
  174.     app_commands.Choice(name = '0', value = 0),
  175.     app_commands.Choice(name = '1', value = 1),
  176.     app_commands.Choice(name = '2', value = 2)
  177. ])
  178. @app_commands.choices(nado = [
  179.     app_commands.Choice(name = '-1', value = -1),
  180.     app_commands.Choice(name = '0', value = 0),
  181.     app_commands.Choice(name = '1', value = 1),
  182.     app_commands.Choice(name = '2', value = 2)
  183. ])
  184. @app_commands.choices(arremesso = [
  185.     app_commands.Choice(name = '-1', value = -1),
  186.     app_commands.Choice(name = '0', value = 0),
  187.     app_commands.Choice(name = '1', value = 1),
  188.     app_commands.Choice(name = '2', value = 2)
  189. ])
  190. @app_commands.choices(percepção = [
  191.     app_commands.Choice(name = '-1', value = -1),
  192.     app_commands.Choice(name = '0', value = 0),
  193.     app_commands.Choice(name = '1', value = 1),
  194.     app_commands.Choice(name = '2', value = 2)
  195. ])
  196. @app_commands.choices(acrobacia = [
  197.     app_commands.Choice(name = '-1', value = -1),
  198.     app_commands.Choice(name = '0', value = 0),
  199.     app_commands.Choice(name = '1', value = 1),
  200.     app_commands.Choice(name = '2', value = 2)
  201. ])
  202. @app_commands.choices(pilotagem = [
  203.     app_commands.Choice(name = '-1', value = -1),
  204.     app_commands.Choice(name = '0', value = 0),
  205.     app_commands.Choice(name = '1', value = 1),
  206.     app_commands.Choice(name = '2', value = 2)
  207. ])
  208. @app_commands.choices(jogodmao = [
  209.     app_commands.Choice(name = '-1', value = -1),
  210.     app_commands.Choice(name = '0', value = 0),
  211.     app_commands.Choice(name = '1', value = 1),
  212.     app_commands.Choice(name = '2', value = 2)
  213. ])
  214. @app_commands.choices(furtividade = [
  215.     app_commands.Choice(name = '-1', value = -1),
  216.     app_commands.Choice(name = '0', value = 0),
  217.     app_commands.Choice(name = '1', value = 1),
  218.     app_commands.Choice(name = '2', value = 2)
  219. ])
  220. @app_commands.choices(conhecimentos = [
  221.     app_commands.Choice(name = '-1', value = -1),
  222.     app_commands.Choice(name = '0', value = 0),
  223.     app_commands.Choice(name = '1', value = 1),
  224.     app_commands.Choice(name = '2', value = 2)
  225. ])
  226. @app_commands.choices(enganação = [
  227.     app_commands.Choice(name = '-1', value = -1),
  228.     app_commands.Choice(name = '0', value = 0),
  229.     app_commands.Choice(name = '1', value = 1),
  230.     app_commands.Choice(name = '2', value = 2)
  231. ])
  232. @app_commands.choices(infiltração = [
  233.     app_commands.Choice(name = '-1', value = -1),
  234.     app_commands.Choice(name = '0', value = 0),
  235.     app_commands.Choice(name = '1', value = 1),
  236.     app_commands.Choice(name = '2', value = 2)
  237. ])
  238. @app_commands.choices(persuasão = [
  239.     app_commands.Choice(name = '-1', value = -1),
  240.     app_commands.Choice(name = '0', value = 0),
  241.     app_commands.Choice(name = '1', value = 1),
  242.     app_commands.Choice(name = '2', value = 2)
  243. ])
  244. @app_commands.choices(sobrevivência = [
  245.     app_commands.Choice(name = '-1', value = -1),
  246.     app_commands.Choice(name = '0', value = 0),
  247.     app_commands.Choice(name = '1', value = 1),
  248.     app_commands.Choice(name = '2', value = 2)
  249. ])
  250. @app_commands.choices(riqueza = [
  251.         app_commands.Choice(name = '0', value = 0),
  252.         app_commands.Choice(name = '1', value = 1),
  253.         app_commands.Choice(name = '2', value = 2),
  254.         app_commands.Choice(name = '3', value = 3),
  255.         app_commands.Choice(name = '4', value = 4),
  256.         app_commands.Choice(name = '5', value = 5),
  257.         app_commands.Choice(name = '6', value = 6),
  258.         app_commands.Choice(name = '7', value = 7),
  259.         app_commands.Choice(name = '8', value = 8)
  260.     ])
  261.  
  262. async def criar(interaction : discord.Interaction, nome : str, idade : int, gênero : str, força : app_commands.Choice[int], reflexos : app_commands.Choice[int], inteligência : app_commands.Choice[int], resistência : app_commands.Choice[int], atletismo : app_commands.Choice[int], pegada : app_commands.Choice[int], nado : app_commands.Choice[int], arremesso : app_commands.Choice[int], percepção : app_commands.Choice[int], acrobacia : app_commands.Choice[int], pilotagem : app_commands.Choice[int], jogodmao : app_commands.Choice[int], furtividade : app_commands.Choice[int], conhecimentos : app_commands.Choice[int], enganação : app_commands.Choice[int], infiltração : app_commands.Choice[int], persuasão : app_commands.Choice[int], sobrevivência : app_commands.Choice[int], vocações : str, fraquezas : str, riqueza : app_commands.Choice[int], destino : int):
  263.  
  264.     with open('info.json', 'r') as file:
  265.         info = json.load(file)
  266.  
  267.     if interaction.user.name not in info['jogadores']:
  268.         info['jogadores'].append(interaction.user.name)
  269.  
  270.         info[str(interaction.user.name)] = {}
  271.    
  272.     info[str(interaction.user.name)][nome] = {
  273.         'nome' : nome,
  274.         'idade' : idade,
  275.         'genero' : gênero,
  276.         'forca' : força.value,
  277.         'reflexos' : reflexos.value,
  278.         'inteligencia' : inteligência.value,
  279.         'resistencia' : resistência.value,
  280.         'atletismo' : atletismo.value,
  281.         'pegada' : pegada.value,
  282.         'nado' : nado.value,
  283.         'arremesso' : arremesso.value,
  284.         'percepcao' : percepção.value,
  285.         'acrobacia' : acrobacia.value,
  286.         'pilotagem' : pilotagem.value,
  287.         'jogo de mao' : jogodmao.value,
  288.         'furtividade' : furtividade.value,
  289.         'conhecimentos' : conhecimentos.value,
  290.         'enganacao' : enganação.value,
  291.         'infiltracao' : infiltração.value,
  292.         'persuasao' : persuasão.value,
  293.         'sobrevivencia' : sobrevivência.value,
  294.         'vocacoes' : vocações,
  295.         'fraquezas' : fraquezas,
  296.         'riqueza' : riqueza.value,
  297.         'destino' : destino
  298.     }
  299.  
  300.     with open('info.json', 'w') as file:
  301.         json.dump(info, file, indent = 1)
  302.    
  303.     await interaction.response.send_message(f'{nome} veio ao mundo {interaction.user.mention}! 😍😍😍')
  304.  
  305.     #endregion
  306.  
  307.     #MUDAR - Altera algo sobre seu personagem
  308.     #region
  309.  
  310. @bot.tree.command(name = 'mudar', description = 'Muda uma propiedade do seu personagem')
  311. @app_commands.describe(propiedade = 'O que você quer mudar no seu personagem', valor = 'O novo valor da propiedade')
  312. @app_commands.choices(propiedade = [
  313.     app_commands.Choice(name = 'nome', value = 'nome'),
  314.     app_commands.Choice(name = 'idade', value = 'idade'),
  315.     app_commands.Choice(name = 'gênero', value = 'genero'),
  316.     app_commands.Choice(name = 'resistência', value = 'resistencia'),
  317.     app_commands.Choice(name = 'atletismo', value = 'atletismo'),
  318.     app_commands.Choice(name = 'pegada', value = 'pegada'),
  319.     app_commands.Choice(name = 'nado', value = 'nado'),
  320.     app_commands.Choice(name = 'arremesso', value = 'arremesso'),
  321.     app_commands.Choice(name = 'percepção', value = 'percepcao'),
  322.     app_commands.Choice(name = 'acrobacia', value = 'acrobacia'),
  323.     app_commands.Choice(name = 'pilotagem', value = 'pilotagem'),
  324.     app_commands.Choice(name = 'jogo de mão', value = 'jogo de mao'),
  325.     app_commands.Choice(name = 'furtividade', value = 'furtividade'),
  326.     app_commands.Choice(name = 'conhecimentos', value = 'conhecimentos'),
  327.     app_commands.Choice(name = 'enganação', value = 'enganacao'),
  328.     app_commands.Choice(name = 'infiltração', value = 'infiltracao'),
  329.     app_commands.Choice(name = 'persuasão', value = 'persuasao'),
  330.     app_commands.Choice(name = 'sobrevivência', value = 'sobrevivencia'),
  331.     app_commands.Choice(name = 'vocações', value = 'vocacoes'),
  332.     app_commands.Choice(name = 'riqueza', value = 'riqueza'),
  333.     app_commands.Choice(name = 'destino', value = 'destino'),
  334. ])
  335.  
  336. async def mudar(interaction : discord.Interaction, propiedade : app_commands.Choice[str], valor : str):
  337.    
  338.     with open('info.json', 'r') as file:
  339.                 info = json.load(file)
  340.  
  341.     if interaction.user.name in info['jogadores']:
  342.  
  343.         if interaction.user.display_name in info[str(interaction.user.name)]:
  344.  
  345.             with open('info.json', 'w') as file:
  346.  
  347.                 if str.isdigit(valor):
  348.                     valor = int(valor)
  349.  
  350.                 info[propiedade.value] = valor
  351.                 json.dump(info, file, indent = 5)
  352.                 await interaction.response.send_message(f'Partabéns {interaction.user.mention}, você alterou o seu DNA')
  353.        
  354.         else:
  355.             await interaction.response.send_message(f'Seu nome precisa ser o mesmo do seu personagem {interaction.user.mention}')
  356.  
  357.     else:
  358.         await interaction.response.send_message(f'Você não tem personagens {interaction.user.mention}')
  359.  
  360.     #endregion
  361.  
  362.     #ROLL - Faz um rolamento
  363.     #region
  364. @bot.tree.command(name = 'roll', description = 'Role alguma habilidade')
  365. @app_commands.describe(habilidade = 'A habilidade que você quer rolar', nd = 'Nível de Dificuldade')
  366. @app_commands.choices(habilidade = [
  367.     app_commands.Choice(name = 'resistência', value = 'resistencia'),
  368.     app_commands.Choice(name = 'atletismo', value = 'atletismo'),
  369.     app_commands.Choice(name = 'pegada', value = 'pegada'),
  370.     app_commands.Choice(name = 'nado', value = 'nado'),
  371.     app_commands.Choice(name = 'arremesso', value = 'arremesso'),
  372.     app_commands.Choice(name = 'percepção', value = 'percepcao'),
  373.     app_commands.Choice(name = 'acrobacia', value = 'acrobacia'),
  374.     app_commands.Choice(name = 'pilotagem', value = 'pilotagem'),
  375.     app_commands.Choice(name = 'jogo de mão', value = 'jogo de mao'),
  376.     app_commands.Choice(name = 'furtividade', value = 'furtividade'),
  377.     app_commands.Choice(name = 'conhecimentos', value = 'conhecimentos'),
  378.     app_commands.Choice(name = 'enganação', value = 'enganacao'),
  379.     app_commands.Choice(name = 'infiltração', value = 'infiltracao'),
  380.     app_commands.Choice(name = 'persuasão', value = 'persuasao'),
  381.     app_commands.Choice(name = 'sobrevivência', value = 'sobrevivencia'),
  382. ])
  383. @app_commands.choices(nd = [
  384.     app_commands.Choice(name = '1', value = 1),
  385.     app_commands.Choice(name = '2', value = 2),
  386.     app_commands.Choice(name = '3', value = 3),
  387.     app_commands.Choice(name = '4', value = 4),
  388.     app_commands.Choice(name = '5', value = 5),
  389.     app_commands.Choice(name = '6', value = 6),
  390.     app_commands.Choice(name = '7', value = 7),
  391.     app_commands.Choice(name = '8', value = 8)
  392. ])
  393. async def roll(interaction : discord.Interaction, habilidade : app_commands.Choice[str], nd : app_commands.Choice[int]):
  394.  
  395.     with open('info.json', 'r') as file:
  396.         info = json.load(file)
  397.  
  398.     if interaction.user.name in info['jogadores']:
  399.  
  400.         if interaction.user.display_name in info[str(interaction.user.name)]:
  401.  
  402.             d6 = range(1, 7)
  403.             jogador = info[interaction.user.name][interaction.user.display_name]
  404.             vitorias = 0
  405.             resultado = f'Nível de dificuldade: {nd.name}\n\n'
  406.             i = 0
  407.  
  408.             if habilidade.name in forHabs:
  409.                 atr = 'forca'
  410.             elif habilidade.name in refHabs:
  411.                 atr = 'reflexos'
  412.             elif habilidade.name in intHabs:
  413.                 atr = 'inteligencia'
  414.  
  415.             atrVal = jogador[atr]
  416.             habVal = jogador[habilidade.value]
  417.             d6Result = 3 + habVal + atrVal
  418.  
  419.             while i < d6Result:
  420.                 d6Num = random.choice(d6)
  421.  
  422.                 if d6Num > 3:
  423.                     vitorias += 1
  424.  
  425.                 resultado += f'Dado {i + 1}: {d6Num}\n'
  426.  
  427.                 i += 1
  428.  
  429.             if vitorias >= nd.value:
  430.                 resultado += f'\n{interaction.user.mention} você completou a ação, com {vitorias} vitória(s)'
  431.             if vitorias < nd.value:
  432.                 resultado += f'\n{interaction.user.mention} você teve {vitorias} vitória(s), e não completou a ação'
  433.             await interaction.response.send_message(resultado)
  434.    
  435.         else:
  436.             await interaction.response.send_message(f'Seu nome precisa ser o mesmo do seu personagem {interaction.user.mention}')
  437.  
  438.     else:
  439.         await interaction.response.send_message(f'Você não tem personagens {interaction.user.mention}')
  440.  
  441. #endregion
  442.  
  443.  
  444.     #CHANCES - Checar chances
  445.     #region
  446. @bot.tree.command(name = 'chances', description = 'Verifica a chance de você conseguir fazer um rolamento')
  447. @app_commands.describe(dados = 'Quantos dados você tem', nd = 'Nível de dificuldade da ação')
  448. @app_commands.choices(dados =[
  449.     app_commands.Choice(name = '1', value = 1),
  450.     app_commands.Choice(name = '2', value = 2),
  451.     app_commands.Choice(name = '3', value = 3),
  452.     app_commands.Choice(name = '4', value = 4),
  453.     app_commands.Choice(name = '5', value = 5),
  454.     app_commands.Choice(name = '6', value = 6),
  455.     app_commands.Choice(name = '7', value = 7),
  456.     app_commands.Choice(name = '8', value = 8),
  457.     app_commands.Choice(name = '9', value = 9),
  458.     app_commands.Choice(name = '10', value = 10),
  459.     app_commands.Choice(name = '11', value = 11),
  460.     app_commands.Choice(name = '12', value = 12),
  461.     app_commands.Choice(name = '13', value = 13),
  462.     app_commands.Choice(name = '14', value = 14),
  463.     app_commands.Choice(name = '15', value = 15),
  464.     app_commands.Choice(name = '16', value = 16),
  465.     app_commands.Choice(name = '17', value = 17),
  466.     app_commands.Choice(name = '18', value = 18),
  467.     app_commands.Choice(name = '19', value = 19),
  468.     app_commands.Choice(name = '20', value = 20)
  469. ])
  470. @app_commands.choices(nd = [
  471.     app_commands.Choice(name = '1', value = 1),
  472.     app_commands.Choice(name = '2', value = 2),
  473.     app_commands.Choice(name = '3', value = 3),
  474.     app_commands.Choice(name = '4', value = 4),
  475.     app_commands.Choice(name = '5', value = 5),
  476.     app_commands.Choice(name = '6', value = 6),
  477.     app_commands.Choice(name = '7', value = 7),
  478.     app_commands.Choice(name = '8', value = 8)
  479. ])
  480. async def chance(interaction : discord.Interaction, dados : app_commands.Choice[int], nd : app_commands.Choice[int]):
  481.  
  482.     with open('info.json', 'r') as file:
  483.                     info = json.load(file)
  484.  
  485.     if interaction.user.name in info['jogadores']:
  486.  
  487.         if interaction.user.display_name in info[str(interaction.user.name)]:
  488.  
  489.             x = 0
  490.             probVal = 0
  491.  
  492.             while (dados.value - x) >= nd.value:
  493.                 prob = binom(dados.value, dados.value - x) * (0.5) ** (dados.value - x) * (0.5) ** (dados.value - (dados.value - x))
  494.                 probVal += prob
  495.                 x += 1
  496.            
  497.             await interaction.response.send_message(f'{dados.name} dado(s) para um desafio nível {nd.name}.\n\nSua chance de sucesso é de {str(probVal * 100)[:4]}%')
  498.  
  499.         else:
  500.                 await interaction.response.send_message(f'Seu nome precisa ser o mesmo do seu personagem {interaction.user.mention}')
  501.  
  502.     else:
  503.         await interaction.response.send_message(f'Você não tem personagens {interaction.user.mention}')
  504.  
  505. #endregion
  506.  
  507.  
  508.     #DADOS - Contar quantos dados tem pra uma habilidade
  509.     #region
  510. @bot.tree.command(name = 'dados', description = 'Conta quantos dados você terá para rolar uma habilidade')
  511. @app_commands.describe(habilidade = 'Qual habilidade você quer checar?')
  512. @app_commands.choices(habilidade =[
  513.     discord.app_commands.Choice(name = 'resistência', value = 'resistencia'),
  514.     discord.app_commands.Choice(name = 'stletismo', value = 'atletismo'),
  515.     discord.app_commands.Choice(name = 'pegada', value = 'pegada'),
  516.     discord.app_commands.Choice(name = 'nado', value = 'nado'),
  517.     discord.app_commands.Choice(name = 'arremesso', value = 'arremesso'),
  518.     discord.app_commands.Choice(name = 'percepção', value = 'percepcao'),
  519.     discord.app_commands.Choice(name = 'acrobacia', value = 'acrobacia'),
  520.     discord.app_commands.Choice(name = 'pilotagem', value = 'pilotagem'),
  521.     discord.app_commands.Choice(name = 'jogo de mão', value = 'jogo de mao'),
  522.     discord.app_commands.Choice(name = 'furtividade', value = 'furtividade'),
  523.     discord.app_commands.Choice(name = 'conhecimentos', value = 'conhecimento geral'),
  524.     discord.app_commands.Choice(name = 'enganação', value = 'enganacao'),
  525.     discord.app_commands.Choice(name = 'infiltração', value = 'infiltracao'),
  526.     discord.app_commands.Choice(name = 'persuasão', value = 'persuasao'),
  527.     discord.app_commands.Choice(name = 'sobrevivência', value = 'sobrevivencia')
  528. ])
  529. async def dados(interaction : discord.Interaction, habilidade : app_commands.Choice[str]):
  530.  
  531.     with open('info.json', 'r') as file:
  532.                     info = json.load(file)
  533.  
  534.     if interaction.user.name in info['jogadores']:
  535.  
  536.         if interaction.user.display_name in info[str(interaction.user.name)]:
  537.  
  538.             jogador = info[interaction.user.name][interaction.user.display_name]
  539.  
  540.             if habilidade.name in forHabs:
  541.                 atr = 'forca'
  542.             elif habilidade.name in refHabs:
  543.                 atr = 'reflexos'
  544.             elif habilidade.name in intHabs:
  545.                 atr = 'inteligencia'
  546.  
  547.             atrVal = jogador[atr]
  548.             habVal = jogador[habilidade.value]
  549.             d6Result = 3 + habVal + atrVal
  550.  
  551.             await interaction.response.send_message(f'Você tem {d6Result} dados base para rolar {(habilidade.name).lower()}.')
  552.    
  553.         else:
  554.                     await interaction.response.send_message(f'Seu nome precisa ser o mesmo do seu personagem {interaction.user.mention}')
  555.  
  556.     else:
  557.         await interaction.response.send_message(f'Você não tem personagens {interaction.user.mention}')
  558.  
  559. #endregion
  560.  
  561.  
  562.     #FICHA - Ver sua ficha
  563.     #region
  564.  
  565. @bot.tree.command(name = 'ficha', description = 'Mostra a sua ficha')
  566.  
  567.  
  568. async def ficha(interaction : discord.Interaction):
  569.  
  570.     with open('info.json', 'r') as file:
  571.                     info = json.load(file)
  572.  
  573.     if interaction.user.name in info['jogadores']:
  574.  
  575.         if interaction.user.display_name in info[str(interaction.user.name)]:
  576.  
  577.             ficha = ''
  578.  
  579.             for index, stat in enumerate(fichaList):
  580.                 ficha += stat[0] + ': ' + str(info[interaction.user.name][interaction.user.display_name][stat[1]]) + '\n'
  581.  
  582.                 if index in [2, 5, 10, 15, 20, 22]:
  583.                     ficha += '\n'
  584.  
  585.             await interaction.response.send_message(ficha)
  586.  
  587.         else:
  588.                 await interaction.response.send_message(f'Seu nome precisa ser o mesmo do seu personagem {interaction.user.mention}')
  589.  
  590.     else:
  591.         await interaction.response.send_message(f'Você não tem personagens {interaction.user.mention}')
  592.  
  593.     #endregion
  594.  
  595.  
  596.  
  597. #INTERAÇÃO
  598.     #Mencionada
  599.     #region
  600.  
  601. @bot.event
  602. async def on_message(message):
  603.     if bot.user.mentioned_in(message):
  604.  
  605.         with open('info.json', 'r') as file:
  606.              info = json.load(file)
  607.        
  608.         clean_message = re.compile('@Auxi').sub('Auxi', message.clean_content)
  609.         info['auxiPergunta'] = clean_message
  610.  
  611.        
  612.         with open('info.json', 'w') as file:
  613.              json.dump(info, file, indent = 1)
  614.  
  615.         await main()
  616.  
  617.         with open('info.json', 'r') as file:
  618.              info = json.load(file)
  619.  
  620.         await message.channel.send(message.author.mention + info['auxiResposta'])
  621.  
  622.  
  623.    
  624.     await bot.process_commands(message)
  625.  
  626.     #endregion
  627.  
  628. bot.run('MTA1ODg0NDMyOTgxODQ3MjQ1OA.GQZ7c_.sdSn_-f9EN-Adt_RtnqhbXWv5sZle1A0ayXXV4')
  629.  
  630.  
Advertisement
Add Comment
Please, Sign In to add comment