Skip to content

Commit

Permalink
refator mini alteracoes na localizacao de rotas e compressao de imagens
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-Santana-j committed Jul 9, 2024
1 parent f7ac3a9 commit cfa49d9
Show file tree
Hide file tree
Showing 20 changed files with 318 additions and 1,152 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ config
config/mercadoPagoData.json


cart.list
ticket.list
/cart.list
117 changes: 117 additions & 0 deletions Discord/discordRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
const express = require('express');
const router = express.Router();

const stripe = require('stripe')(require('../config/web-config').stripe);

const db = require('../Firebase/models')
const fs = require('fs');
const functions = require('../functions');
const webConfig = require('../config/web-config');
const sharp = require('sharp');

const { default: axios } = require("axios");

router.get('/auth/verify/:acesstoken', async (req, res) => {
let param = req.params.acesstoken
if (param) {
try {
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'application/x-www-form-urlencoded'
};
let userResponse = await axios.get('https://discord.com/api/users/@me', {
headers: {
Authorization: `Bearer ${param}`,
...headers
}
}).then((res) => { return res.data })
if (userResponse) {
req.session.uid = userResponse.id
res.redirect('/dashboard')
} else {
res.redirect(webConfig.loginURL)
}
} catch (error) {
res.redirect(webConfig.loginURL)
}
} else {
res.redirect(webConfig.loginURL)
}
})



router.get('/auth/callback', async (req, res) => {
try {
if (req.session.uid) {
res.redirect('/dashboard')
} else {
if (!req.query.code) {
res.redirect('/logout')
} else {
let param = new URLSearchParams({
client_id: webConfig.clientId,
client_secret: webConfig.secret,
grant_type: 'authorization_code',
code: req.query.code,
redirect_uri: webConfig.redirect
})
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept-Encoding': 'application/x-www-form-urlencoded'
};
const response = await axios.post('https://discord.com/api/oauth2/token', param, { headers }).then((res) => { return res }).catch((err) => {
console.error(err)
})
if (!response) {
res.redirect('/logout')
return
}
let userResponse = await axios.get('https://discord.com/api/users/@me', {
headers: {
Authorization: `Bearer ${response.data.access_token}`,
...headers
}
}).then((res) => { return res.data }).catch((err) => {
console.error(err)
});
await db.create('users', userResponse.id, {
id: userResponse.id,
username: userResponse.username,
profile_pic: userResponse.avatar ? `https://cdn.discordapp.com/avatars/${userResponse.id}/${userResponse.avatar}.png` : 'https://res.cloudinary.com/dgcnfudya/image/upload/v1709143898/gs7ylxx370phif3usyuf.png',
displayName: userResponse.global_name,
email: userResponse.email,
access_token: response.data.access_token
})

req.session.uid = userResponse.id

res.redirect('/dashboard')
}
}
} catch (error) {
res.redirect('/logout')
}
})




router.get('/addbot/:serverID', (req, res) => {
if (!req.params.serverID) {
res.redirect(`/`)
return
}
const guilds = client.guilds.cache;
const isBotInServer = guilds.has(req.params.serverID);
if (isBotInServer) {
res.redirect(`/server/${req.body.serverID}`)
} else {
res.redirect(`https://discord.com/oauth2/authorize?client_id=${webConfig.clientId}&permissions=8&response_type=code&scope=bot+applications.commands+guilds.members.read+applications.commands.permissions.update&redirect_uri=${process.env.DISCORDURI}&guild_id=${req.params.serverID}&disable_guild_select=true`)
}

})



module.exports = router;
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<div align="center" id="top">
<img src="./.github/app.gif" alt="Sdkbot" />

&#xa0;

<!-- <a href="https://sdkbot.netlify.app">Demo</a> -->
</div>

<h1 align="center">Sdkbot</h1>

<p align="center">
<img alt="Github top language" src="https://img.shields.io/github/languages/top/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8">

<img alt="Github language count" src="https://img.shields.io/github/languages/count/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8">

<img alt="Repository size" src="https://img.shields.io/github/repo-size/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8">

<img alt="License" src="https://img.shields.io/github/license/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8">

<!-- <img alt="Github issues" src="https://img.shields.io/github/issues/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8" /> -->

<!-- <img alt="Github forks" src="https://img.shields.io/github/forks/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8" /> -->

<!-- <img alt="Github stars" src="https://img.shields.io/github/stars/{{YOUR_GITHUB_USERNAME}}/sdkbot?color=56BEB8" /> -->
</p>

<!-- Status -->

<!-- <h4 align="center">
🚧 Sdkbot 🚀 Under construction... 🚧
</h4>
<hr> -->

<p align="center">
<a href="#dart-about">About</a> &#xa0; | &#xa0;
<a href="#sparkles-features">Features</a> &#xa0; | &#xa0;
<a href="#rocket-technologies">Technologies</a> &#xa0; | &#xa0;
<a href="#white_check_mark-requirements">Requirements</a> &#xa0; | &#xa0;
<a href="#checkered_flag-starting">Starting</a> &#xa0; | &#xa0;
<a href="#memo-license">License</a> &#xa0; | &#xa0;
<a href="https://github.com/{{YOUR_GITHUB_USERNAME}}" target="_blank">Author</a>
</p>

<br>

## :dart: About ##

Describe your project

## :sparkles: Features ##

:heavy_check_mark: Feature 1;\
:heavy_check_mark: Feature 2;\
:heavy_check_mark: Feature 3;

## :rocket: Technologies ##

The following tools were used in this project:

- [Expo](https://expo.io/)
- [Node.js](https://nodejs.org/en/)
- [React](https://pt-br.reactjs.org/)
- [React Native](https://reactnative.dev/)
- [TypeScript](https://www.typescriptlang.org/)

## :white_check_mark: Requirements ##

Before starting :checkered_flag:, you need to have [Git](https://git-scm.com) and [Node](https://nodejs.org/en/) installed.

## :checkered_flag: Starting ##

```bash
# Clone this project
$ git clone https://github.com/{{YOUR_GITHUB_USERNAME}}/sdkbot

# Access
$ cd sdkbot

# Install dependencies
$ yarn

# Run the project
$ yarn start

# The server will initialize in the <http://localhost:3000>
```

## :memo: License ##

This project is under license from MIT. For more details, see the [LICENSE](LICENSE.md) file.


Made with :heart: by <a href="https://github.com/{{YOUR_GITHUB_USERNAME}}" target="_blank">{{YOUR_NAME}}</a>

&#xa0;

<a href="#top">Back to top</a>
10 changes: 0 additions & 10 deletions handler/commands/util/ping.js

This file was deleted.

10 changes: 0 additions & 10 deletions handler/commands/util/ticket.js

This file was deleted.

Loading

0 comments on commit cfa49d9

Please sign in to comment.