Add error message in dashboard
This commit is contained in:
@@ -5,7 +5,7 @@ from discord import Member
|
||||
from discord.ext import commands
|
||||
|
||||
def missingPermission(user_id:int):
|
||||
payload = {"op": "missingPermission", "msg": "Only the DJ or admins may use this funciton!"}
|
||||
payload = {"op": "errorMsg", "level": "info", "msg": "Only the DJ or admins may use this funciton!"}
|
||||
payload["user_id"] = user_id
|
||||
return payload
|
||||
|
||||
@@ -176,5 +176,11 @@ async def process_methods(websocket, bot: commands.Bot, data: dict) -> None:
|
||||
resp: dict = await method(player, member, data)
|
||||
if resp:
|
||||
await websocket.send(json.dumps(resp))
|
||||
except:
|
||||
return
|
||||
except Exception as e:
|
||||
payload = {
|
||||
"op": "errorMsg",
|
||||
"level": "info",
|
||||
"msg": e,
|
||||
"user_id": member.id
|
||||
}
|
||||
await websocket.send(json.dumps(payload))
|
||||
BIN
web/static/img/error.png
Normal file
BIN
web/static/img/error.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
web/static/img/info.png
Normal file
BIN
web/static/img/info.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -169,6 +169,10 @@ const actions = {
|
||||
repeatTrack: function (player, data) {
|
||||
player.repeat = data["repeatMode"];
|
||||
},
|
||||
|
||||
errorMsg: function (player, data) {
|
||||
var level = data["level"];
|
||||
player.showToast(level, data["msg"]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -323,7 +327,13 @@ class Player {
|
||||
}
|
||||
|
||||
showToast(userId, msg) {
|
||||
var user = this.users[userId];
|
||||
if (userId == "info") {
|
||||
var user = { avatar_url: "/static/img/info.png", name: "Info" }
|
||||
} else if (userId == "error") {
|
||||
var user = { avatar_url: "/static/img/error.png", name: "Error" }
|
||||
} else {
|
||||
var user = this.users[userId];
|
||||
}
|
||||
if (user != null) {
|
||||
var $element = $(`<div class="toast"><img src=${user['avatar_url']} alt="user-icon"/><div class="content"><p class="username">${user['name']}</p><p class="message">${msg}</p></div></div>`)
|
||||
$(".toastContrainer").append($element)
|
||||
|
||||
Reference in New Issue
Block a user