Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnvironmentVariablesError("BOT_TOKEN"); #1

Closed
CentroEducacional-CEC opened this issue Aug 25, 2022 · 2 comments
Closed

EnvironmentVariablesError("BOT_TOKEN"); #1

CentroEducacional-CEC opened this issue Aug 25, 2022 · 2 comments

Comments

@CentroEducacional-CEC
Copy link

Obtive esse erro ao iniciar, mas o Token está correto e já o uso em outro bot!

bot-blaze-telegram@0.1.0 start
node src/index.mjs


| __ )| | __ _ _______ __ () || |__ | || | ___ __ _ _ __ __ _ _ __ ___
| _ | |/ _ |_ / _ \ \ \ /\ / / | __| '_ \ | |/ _ \ |/ _ \/ _ | '
/ | '_ _
| |
) | | (
| |/ / / \ V V /| | || | | | | | __/ | __/ (| | | | (| | | | | | |
|
/||_,/
_| _/_/ ||_|| || |_|_|_|_|_, || _,|| || ||
|
_/
by: Elizandro Dantas

  • Iniciando servidorfile:///C:/Users/SERVIDOR/Desktop/Bot2/bot-blaze-telegram/src/core/telegram.mjs:30
    throw new EnvironmentVariablesError("BOT_TOKEN");
    ^

EnvironmentVariablesError: error environment veriables: [BOT_TOKEN]
at new Telegram (file:///C:/Users/SERVIDOR/Desktop/Bot2/bot-blaze-telegram/src/core/telegram.mjs:30:15)
at new BotBlazeWithTelegram (file:///C:/Users/SERVIDOR/Desktop/Bot2/bot-blaze-telegram/src/middleware/bot.mjs:16:21)
at start (file:///C:/Users/SERVIDOR/Desktop/Bot2/bot-blaze-telegram/src/index.mjs:23:25)
at file:///C:/Users/SERVIDOR/Desktop/Bot2/bot-blaze-telegram/src/index.mjs:14:5
at C:\Users\SERVIDOR\Desktop\Bot2\bot-blaze-telegram\node_modules\figlet\lib\figlet.js:858:13
at C:\Users\SERVIDOR\Desktop\Bot2\bot-blaze-telegram\node_modules\figlet\lib\node-figlet.js:30:13
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)

Node.js v17.8.0

@elizandrodantas
Copy link
Owner

elizandrodantas commented Aug 25, 2022

A variáveis ambiente não foi encontrada, configuração citada em Instalação#Variaveis Ambiente#3

Soluções:

  1. Você pode alterar nome do arquivo .env.example para .env e preenche os campos [BOT_TOKEN e ID_GROUP_MESSAGE]
  2. Setar variaveis de ambiente no sistema (você pode pesquisar mais sobre no google)

Uso em dev

  • yarn
yarn dev
  • npm
npm run dev

Obs.: apenas o script de dev consegue implementar as variáveis ambiente do arquivo .env no sistema, caso execute outro arquivo/script preciso setar direto no sistema.

Mais sobre variáveis ambiente nodejs

@CentroEducacional-CEC
Copy link
Author

Já o tinha feito, hoje ao tentar novamente vi que o problema era a forma que eu estava tentando iniciar o bot! a correta é com esse comando!

node example/example-with-dotenv.mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants