如何使Discord机器人保持清醒状态(摆脱“应用程序错误”)

时间:2019-12-27 09:51:31

标签: heroku heroku-api

因此,由于有Heroku,我有一个(很少)Discord机器人进入睡眠状态,并且我试图使用Kaffeine使其保持清醒状态,但我从Kaffeine获得了 const userAPI = 'http://localhost:5050/api/new/users' const urlHistory = 'http://localhost:5050/api/vote/historyvote/' const urlArrayHistory = 'http://localhost:5050/api/vote/array/' const realUsers = [] const SCREEN_WIDTH = Dimensions.get('window').width; const SCREEN_HEIGHT = Dimensions.get('window').height; export default class HomeScreen extends React.Component{ constructor(props){ super(props) this.position = new Animated.ValueXY() this.state={ currentIndex : 0, idUser : null, nameUser : null, scoreUser : null, currentAdverseId :"", currentToken : this.props.screenProps.jwt, readyRender : 0, voteHistory : [], } this.infoUserAdverse = { name :"", age : "", Score:"", idAdverse :"" } } retrieveId = () =>{ //Get back the Id of current logged in user from the token const header = { 'authorization':'Bearer '+this.props.screenProps.jwt } console.log(header) axios.get('http://localhost:5050/api/posts',{ headers : header }) .then((response) =>{ console.log(response) this.setState({idUser: response.data._id}) console.log(this.state.idUser) }) .catch((error)=>{ console.log(error) }) } historyUsers = () =>{ axios({ method:'GET', url : urlArrayHistory+this.state.idUser }) .then((response)=>{ console.log("response de historyVote",response) const realUsersId = [] for(let p=0; p<realUsers.length;p++){ realUsersId.push(realUsers[p]._id) } for(let k = 0;k<response.data[0].historyVote.length;k++){ if(realUsersId.includes(response.data[0].historyVote[k])){ console.log("it's in",realUsers) realUsers.pop(k) console.log(realUsers) } else{ console.log("ain't in") } } }) } fetchUsers = () => { axios.get(userAPI) //Array from all users in DB .then((res)=>{ for(var k = 0; k <(res.data.length); k++){ if(this.state.idUser==res.data[k]._id){ console.log("forget same user") } else { realUsers.push(res.data[k]) } } console.log(realUsers) }) } apiFetchId = () => { const newHeader = { 'authorization':'Bearer '+this.state.currentToken } axios.get('http://localhost:5050/api/new/'+this.state.idUser,{ headers: newHeader }) .then((res)=>{ console.log(res) this.setState({ nameUser:res.data.name, scoreUser:res.data.Score, voteHistory:res.data.historyVote }) }) } componentDidMount(){ this.fetchUsers() this.apiFetchId() //this.historyUsers() //this.renderUsers() } renderUsers = () => { return realUsers.map((item, i) => { if(i< this.state.currentIndex){ return null } else if (i == this.state.currentIndex){ console.log("render users cas 2") this.infoUserAdverse=realUsers[i] return ( <Animated.View {...this.PanResponder.panHandlers} key={item._id} style={[this.rotateAndTranslate , { height: SCREEN_HEIGHT - 220, width: SCREEN_WIDTH, padding: 10, position: 'absolute' }]}> <Animated.View style={{ opacity: this.likeOpacity, transform: [{ rotate: '-30deg' }], position: 'absolute', top: 50, left: 40, zIndex: 1000 }}> <Text style={{ borderWidth: 1, borderColor: 'green', color: 'green', fontSize: 32, fontWeight: '800', padding: 10 }}>++</Text> </Animated.View> <Animated.View style={{ opacity: this.dislikeOpacity, transform: [{ rotate: '30deg' }], position: 'absolute', top: 50, right: 40, zIndex: 1000 }}> <Text style={{ borderWidth: 1, borderColor: 'red', color: 'red', fontSize: 32, fontWeight: '800', padding: 10 }}>--</Text> </Animated.View> <Image style={{ flex: 1, height: null, width: null, resizeMode: 'cover', borderRadius: 20 }} source={{uri:"http://localhost:5050/"+item.userImage}} /> </Animated.View> ) } else { console.log("render users cas 3") return ( <Animated.View key={item._id} style={[{ opacity: this.nextCardOpacity, transform: [{scale: this.nextCardScale}], height: SCREEN_HEIGHT - 220, width: SCREEN_WIDTH, padding: 10, position: 'absolute' }]}> <Image style={{ flex: 1, height: null, width: null, resizeMode: 'cover', borderRadius: 20 }} source={item.uri} /> </Animated.View> ) } }).reverse() } addHisotryUser = () => { let urlHistory2 = urlHistory+this.state.idUser console.log(urlHistory2) axios({ method: 'PATCH', url: urlHistory2, //headers: {authorization: 'Bearer '+this.state.currentToken}, data: { userId: this.infoUserAdverse._id, } }) .then((res)=>{ console.log(res) }) .catch((err)=>{ console.log(err) }) } :尝试打开机器人的应用程序时,出现“应用程序错误”。我该如何解决? Heroku还建议尝试使用控制台,但我不知道如何访问应用程序的控制台。 (我将所有机器人代码都放在了私有的Github存储库中,这样我的令牌就不会泄露)

这通常是我得到的错误:

我的机器人的代码运行得非常好,而我的dynos是:

网络:npm开始

ezyalts:节点。

0 个答案:

没有答案