import React from 'react'; import Dropzone from 'react-dropzone'; import axios from 'axios'; import SoundList from './SoundList.component'; import './Soundboard.scss'; let self; export default class Soundboard extends React.Component { constructor() { super(); this.state = { percentCompleted: 0, password: "", uploaded: false, uploadError: " ", } self = this; } componentDidMount() { this.config = { headers: { 'Content-Type': 'multipart/form-data', }, onUploadProgress: (progressEvent) => { this.setState({ percentCompleted: Math.round( (progressEvent.loaded * 100) / progressEvent.total ), }); } }; } onDrop(acceptedFiles, rejectedFiles) { if (acceptedFiles.length > 0) { self.uploadFile(acceptedFiles[0]); } } uploadFile(file) { let formData = new FormData(); formData.append("name", file.name); formData.append("file", file); formData.append("password", this.state.password); axios.put("/upload", formData, this.config) .then((response) => { this.setState({ password: "", percentCompleted: 0, uploaded: true, uploadError: " ", }); // reset sound list cache and load the new list this.refs.SoundList.soundListCache = undefined; this.refs.SoundList.getSoundList(); }).catch((err) => { this.setState({ percentCompleted: 0, uploaded: false, uploadError: err.response.data, }); }); } passwordOnChange(event) { this.setState({ password: event.target.value, }); } render() { return (
Discord Sound Bot

Drag and drop files to upload. The sounds can then be played in discord by typing the commands below.

Check out the source code on GitHub

Follow the readme to set up your own bot!

Drop file here to upload.
{this.state.percentCompleted > 0 ?
Uploading: {this.state.percentCompleted}
: ""} {this.state.uploaded ?
File uploded!
: ""}
{this.state.uploadError}
) } }