-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from thirdweb-dev/dev
Showing
8 changed files
with
351 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { Events } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: Events.Error, | ||
once: false, | ||
execute(error) { | ||
console.log(`Not ready due to ${error}`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { Events, ActivityType } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: Events.ClientReady, | ||
once: true, | ||
execute(bot) { | ||
bot.user?.setPresence({ | ||
activities: [{ | ||
name: 'for support.', | ||
type: ActivityType.Watching | ||
}] | ||
}); | ||
|
||
console.log(`Ready! Logged in as ${bot.user.tag}`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { EmbedBuilder } = require('discord.js'); | ||
const moment = require('moment'); | ||
const config = require('../config.json'); | ||
|
||
/** | ||
* send embed message | ||
* @param {string} message | ||
* @returns pre-defined embed style | ||
*/ | ||
const sendEmbedMessage = (message) => { | ||
return new EmbedBuilder() | ||
.setDescription(message) | ||
.setColor(`#f213a4`); | ||
} | ||
|
||
/** | ||
* format time according to UTC | ||
* @param {number} date - epoch timestamp | ||
* @returns time and date format | ||
*/ | ||
const formatTime = (date) => { | ||
return moment.utc(date).utcOffset(config.utc_offset).format('M/DD/YYYY HH:mm:ss'); | ||
} | ||
|
||
/** | ||
* get username from ownerid/author.id | ||
* @param {number} id user's id | ||
* @returns | ||
*/ | ||
const getUsernameFromId = async (id) => { | ||
return (await client.users.fetch(id)).username; | ||
} | ||
|
||
module.exports = { | ||
sendEmbedMessage, | ||
formatTime, | ||
getUsernameFromId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const config = require('../config.json'); | ||
const { GoogleSpreadsheet } = require('google-spreadsheet'); | ||
require('dotenv').config(); | ||
|
||
// load the spreadsheet | ||
const doc = new GoogleSpreadsheet(process.env.GOOGLE_SPREADSHEET_ID); | ||
|
||
/** | ||
* sends data to the spreadsheet | ||
* @param {object} data - data being added as row in the spreadsheet | ||
* @param {string} datasheet - name of sheet where data being sent e.g. init, response, resolve | ||
*/ | ||
const sendData = async (data, datasheet) => { | ||
// authenticate | ||
await doc.useServiceAccountAuth({ | ||
client_email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL, | ||
private_key: process.env.GOOGLE_PRIVATE_KEY.replace(/\\n/g, "\n"), | ||
}); | ||
// load the "initial" sheet | ||
await doc.loadInfo(); | ||
const sheet = doc.sheetsByTitle[datasheet]; | ||
|
||
// check if the data will be send to init sheet | ||
if (datasheet === config.datasheet_init) { | ||
await sheet.addRow(data); | ||
}; | ||
|
||
// check if the data will be send to response sheet | ||
if (datasheet === config.datasheet_response) { | ||
await sheet.addRow(data); | ||
} | ||
|
||
// check if the data will be send to resolve sheet | ||
if (datasheet === config.datasheet_resolve) { | ||
await sheet.addRow(data); | ||
}; | ||
|
||
// check if the data will be send to close sheet | ||
if (datasheet === config.datasheet_close) { | ||
await sheet.addRow(data); | ||
}; | ||
} | ||
|
||
module.exports = { | ||
sendData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters