forked from discord/embedded-app-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (36 loc) · 1.04 KB
/
index.ts
File metadata and controls
43 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {MessageInterface} from '../utils/MessageInterface';
const messageInterface = new MessageInterface();
window.addEventListener('DOMContentLoaded', async () => {
await messageInterface.ready();
messageInterface.sendMessage({
command: 'SET_ACTIVITY',
data: {
activity: {
details: 'Set Activity from nested iframe',
type: 0,
state: 'Playing',
},
},
});
const parentQueryParams = new URLSearchParams(window.parent.location.search);
const channelId = parentQueryParams.get('channel_id');
messageInterface.subscribe(
'SPEAKING_START',
({user_id}) => {
console.log(`"${user_id}" Just started talking`);
},
{channel_id: channelId}
);
messageInterface.subscribe(
'SPEAKING_STOP',
({user_id}) => {
console.log(`"${user_id}" Just stopped talking`);
},
{channel_id: channelId}
);
const reloadButton = document.getElementById('reload');
reloadButton?.addEventListener('click', () => {
console.log('reloading');
window.location.reload();
});
});