当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js.Client.login方法代码示例

本文整理汇总了TypeScript中discord.js.Client.login方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.Client.login方法的具体用法?TypeScript js.Client.login怎么用?TypeScript js.Client.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.js.Client的用法示例。


在下文中一共展示了js.Client.login方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getClient

 public async getClient(userId: string | null = null): Promise<DiscordClient> {
     if (userId === null) {
         return this.botClient;
     }
     if (this.clients.has(userId)) {
         log.verbose("Returning cached user client for", userId);
         return this.clients.get(userId) as DiscordClient;
     }
     const discordIds = await this.store.get_user_discord_ids(userId);
     if (discordIds.length === 0) {
         return Promise.resolve(this.botClient);
     }
     // TODO: Select a profile based on preference, not the first one.
     const token = await this.store.get_token(discordIds[0]);
     const client = new DiscordClient({
         fetchAllMembers: true,
         messageCacheLifetime: 5,
         sync: true,
     });
     const jsLog = new Log("discord.js-ppt");
     client.on("debug", (msg) => { jsLog.verbose(msg); });
     client.on("error", (msg) => { jsLog.error(msg); });
     client.on("warn", (msg) => { jsLog.warn(msg); });
     try {
         await client.login(token);
         log.verbose("Logged in. Storing ", userId);
         this.clients.set(userId, client);
         return client;
     } catch (err) {
         log.warn(`Could not log ${userId} in. Returning bot user for now.`, err);
         return this.botClient;
     }
 }
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:33,代码来源:clientfactory.ts

示例2: async

 return new Bluebird<string>((resolve, reject) => {
     client.on("ready", async () => {
         const id = client.user.id;
         await client.destroy();
         resolve(id);
     });
     client.login(token).catch(reject);
 }).timeout(READY_TIMEOUT).catch((err: Error) => {
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:8,代码来源:clientfactory.ts

示例3: createConnection

createConnection(connectionOptions).then(conn => {
    try {
    console.log("Typeorm connected to database.");

    var bot = new Discord.Client();

    bot.on('ready', () => readyEvent(bot));
    bot.on('presenceUpdate', presenceEvent);
    bot.on('message', messageEvent(bot));

    bot.login(Configuration.DISCORD_TOKEN);
    } catch (ex) {
        console.error(ex);
    }
}).catch(err => {
开发者ID:Goyatuzo,项目名称:LurkerBot,代码行数:15,代码来源:app.ts

示例4: constructor

    constructor(config){
        this.token = config.token;
        this.prefix = config.prefix;
        this.presence = config.presence;

        this.database = new DB();

        this.client = new Client(); // init the discord client
        this.client.login(this.token); // login to the discord API
        
        this.commandHandler = new CommandHandler();

        this.guilds = [];
        
        this.loadCommands();
    }
开发者ID:Avuxo,项目名称:senjou,代码行数:16,代码来源:senjou.ts

示例5: joinChannel

})
/**
 * Handle adding reactions
 */
client.on(`messageReactionAdd`, (reaction: MessageReaction, user: GuildMember) => {
  if(reaction.message.channel.id === config.channelList) {
    joinChannel(user, reaction.message.guild, reaction.message.content.split(` `, 1))
  }
})
/**
 * Handle removing reactions
 */
client.on(`messageReactionRemove`, (reaction: MessageReaction, user: GuildMember) => {
  if(reaction.message.channel.id === config.channelList) {
    leaveChannel(user, reaction.message.guild, reaction.message.content.split(` `, 1))
  }
})
client.on(`raw`, rawEvent => rawReactionEmitter(rawEvent, client))
/**
 * As soon as the bot is up and ready, confirm to console
 * @listens ready
 */
client.on(`ready`, () => {
  console.log(`Logged in as ${client.user.tag}!`)
})
/*
  ------------ EXECUTIONS ------------
*/
// Attempt to login by reading token from file
client.login(config.token)
开发者ID:Zunon,项目名称:Sagiri,代码行数:30,代码来源:main.ts

示例6: ReactionCollector

	disableEveryone: false,
	disabledEvents: ['GUILD_MEMBER_ADD']
});

client.on('message', (message) => {
	if (message.content === 'hello') {
		message.channel.sendMessage('o/');
	}

	const collector: ReactionCollector = new ReactionCollector(message,
		(reaction: MessageReaction) => reaction.emoji.toString() === '👌',
		{ time: 30e3 });
	collector.on('end', collected => console.log(collected));
});

client.login('dsfsd754.4fds4f68d4f6sd46f4s.7878easfdsgdfFDSIJIO');

export class TestCollector extends Collector<Snowflake, Message> {
	public filter: CollectorFilter;
	public constructor(client: Client, filter: CollectorFilter, ) {
		super(client, filter);
	}

	public handle(message: Message): CollectorHandler<Snowflake, Message> {
		return { key: message.id, value: message };
	}

	public cleanup(): void {}
	public postCheck(): null { return null; }
}
开发者ID:Mstrodl,项目名称:mstrodl.github.io,代码行数:30,代码来源:discord.js-test.ts

示例7: resolve

 return new Bluebird<void>((resolve, reject) => {
     this.botClient.on("ready", () => {
         resolve();
     });
     this.botClient.login(this.config.botToken).catch(reject);
 }).timeout(READY_TIMEOUT).catch((err) => {
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:6,代码来源:clientfactory.ts


注:本文中的discord.js.Client.login方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。