Update log storage plugin example for beta.3
parent
b80cb0ed15
commit
bf4920f4b0
|
@ -36,18 +36,18 @@ To use this custom attachment storage type, you would set the `attachmentStorage
|
||||||
|
|
||||||
### Example of a custom log storage type
|
### Example of a custom log storage type
|
||||||
This example adds a custom type for the `logStorage` option called `"pastebin"` that uploads logs to Pastebin.
|
This example adds a custom type for the `logStorage` option called `"pastebin"` that uploads logs to Pastebin.
|
||||||
The code that handles API calls to Pastebin is left out, as it's not relevant to the example.
|
|
||||||
```js
|
```js
|
||||||
module.exports = function({ logs, formatters }) {
|
module.exports = function({ logs, formatters }) {
|
||||||
logs.addStorageType('pastebin', {
|
logs.addStorageType('pastebin', {
|
||||||
async save(thread, threadMessages) {
|
async save(thread, threadMessages) {
|
||||||
const formatLogResult = await formatters.formatLog(thread, threadMessages);
|
const formatLogResult = await formatters.formatLog(thread, threadMessages);
|
||||||
// formatLogResult.content contains the log text
|
const pastebinUrl = await saveToPastebin(formatLogResult); // saveToPastebin is an example function that returns the pastebin URL for the saved log
|
||||||
// Some code here that uploads the full text to Pastebin, and stores the Pastebin link in the database
|
return { url: pastebinUrl };
|
||||||
},
|
},
|
||||||
|
|
||||||
getUrl(threadId) {
|
getUrl(thread) {
|
||||||
// Find the previously-saved Pastebin link from the database based on the thread id, and return it
|
return thread.log_storage_data.url;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue