Skip to content

Commit

Permalink
docs: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Apr 4, 2020
1 parent 8be7e06 commit b0de875
Showing 1 changed file with 73 additions and 39 deletions.
112 changes: 73 additions & 39 deletions examples/upload-story.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { IgApiClient } from '../src';
import { readFile } from 'fs';
import { DateTime, Duration } from 'luxon';

import { StickerBuilder} from '../src/sticker-builder';
import { StickerBuilder } from '../src/sticker-builder';
import { promisify } from 'util';

const readFileAsync = promisify(readFile);

const ig = new IgApiClient();
Expand Down Expand Up @@ -48,48 +49,81 @@ async function login() {
file,
// this creates a new config
stickerConfig: new StickerBuilder()
// these are all supported stickers
.add(StickerBuilder.hashtag({
tagName: 'insta',
}).center())
.add(StickerBuilder.mention({
userId: ig.state.cookieUserId,
}).center())
.add(StickerBuilder.question({
question: 'My Question',
}).scale(0.5))
.add(StickerBuilder.question({
question: 'Music?',
questionType: 'music',
}))
.add(StickerBuilder.countdown({
text: 'My Countdown',
// @ts-ignore
endTs: DateTime.local().plus(Duration.fromObject({ hours: 1 })), // countdown finishes in 1h
}))
.add(StickerBuilder.chat({
text: 'Chat name',
}))
.add(StickerBuilder.location({
locationId: (await ig.locationSearch.index(13, 37)).venues[0].external_id,
}))
.add(StickerBuilder.poll({
question: 'Question',
tallies: [{ text: 'Left' }, { text: 'Right' }],
}))
.add(StickerBuilder.quiz({
question: 'Question',
options: ['0', '1', '2', '3'],
correctAnswer: 1,
}))
.add(StickerBuilder.slider({
question: 'Question',
emoji: '❤',
}))
// these are all supported stickers
.add(
StickerBuilder.hashtag({
tagName: 'insta',
}).center(),
)
.add(
StickerBuilder.mention({
userId: ig.state.cookieUserId,
}).center(),
)
.add(
StickerBuilder.question({
question: 'My Question',
}).scale(0.5),
)
.add(
StickerBuilder.question({
question: 'Music?',
questionType: 'music',
}),
)
.add(
StickerBuilder.countdown({
text: 'My Countdown',
// @ts-ignore
endTs: DateTime.local().plus(Duration.fromObject({ hours: 1 })), // countdown finishes in 1h
}),
)
.add(
StickerBuilder.chat({
text: 'Chat name',
}),
)
.add(
StickerBuilder.location({
locationId: (await ig.locationSearch.index(13, 37)).venues[0].external_id,
}),
)
.add(
StickerBuilder.poll({
question: 'Question',
tallies: [{ text: 'Left' }, { text: 'Right' }],
}),
)
.add(
StickerBuilder.quiz({
question: 'Question',
options: ['0', '1', '2', '3'],
correctAnswer: 1,
}),
)
.add(
StickerBuilder.slider({
question: 'Question',
emoji: '❤',
}),
)

// mention the first story item
.add(StickerBuilder.mentionReel((await ig.feed.userStory('username').items())[0]).center())

// mention the first media on your timeline
.add(StickerBuilder.attachmentFromMedia((await ig.feed.timeline().items())[0]).center())

// you can also set different values for the position and dimensions
.add(
StickerBuilder.hashtag({
tagName: 'insta',
width: 0.5,
height: 0.5,
x: 0.5,
y: 0.5,
}),
)
.build(),
});
})();

0 comments on commit b0de875

Please sign in to comment.